Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] make url shorter .htaccess

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #30499
    coffeendonut
    Member

    i want to know if is it possible to hide the file extension example if i have

    http://mysite.com/thisnew.html rewrite it to http://mysite.com/thisnew

    another example

    https://css-tricks.com/forums/categories/css

    i use the following .htaccess code


    RewriteEngine on
    RewriteRule ^mynew/$ /mynew.html [L]
    RewriteRule ^most/$ /most.php [L]

    is there a way on making this hide all the html extension and not having to include all the page’s on the htaccess file .?

    #78230
    Chris Coyier
    Keymaster
    #78201
    coffeendonut
    Member

    @CWDESIGN some are index but others ain’t as the example above http://www.mysite.com/mynew.html/ becomes http://www.mysite.com/mynew/ an is not an index on a folder im trying basically to remove every .html to just the name without having to write every page on the .htaccess file…

    #78191
    coffeendonut
    Member

    @dclardy thats good i have tried that but i need to remove every .html and .php extension and not having to name it something else… basically no file extensions…

    #78192
    Chris Coyier
    Keymaster

    What you’re trying to do just doesn’t make sense to me. What I think I understand is that you want to remove the “.html” and “.php”.

    #78193
    coffeendonut
    Member

    @CWDESIGN yes… the .html and the .php extension…

    #78189
    Chris Coyier
    Keymaster

    Well, the only way I know how to remove the .html and .php extensions is to create a folder and put index.html or index.php inside of that folder. Adding a folder and naming the file index will make it so your page will look like this mysite.com/thisnew without showing the .html or .php extension.

    #78190
    coffeendonut
    Member

    @CWDESIGN yeah thats the original way that works… cause thats the index of the folder but im not trying to make multiple folders just for a page… thats where the .htaccess come’s in handy the .htaccess file above renames the the file to which ever name you want like RewriteRule ^most/$ /most.php [L] the url will be http://www.mysite.com/most/ without having to make or name a folder and put and index on it…

    #78181
    Chris Coyier
    Keymaster

    I SEE! I was confused as to what you were trying to do. Now that makes sense.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘CSS’ is closed to new topics and replies.