Treehouse: Grow your CSS skills. Land your dream job.

How do I remove the html from /contact.html?

  • # November 5, 2011 at 3:15 pm

    I don’t like the look of my address bar on my website when it says for example, /contact.html. Now I have no idea how to use .htaccess and php worked quiet well for me in other things, so if you know how to do it in php please respond. Or if you can tell me how to use .htaccess that would be cool!

    # November 5, 2011 at 8:01 pm
    RewriteRule ^contact$ contact.html [L]
    # November 6, 2011 at 5:08 am
    RewriteRule ^([^.]+)$ $1.html [NC,L]
    # November 6, 2011 at 5:29 am

    @joelmb has the better solution which removes ALL of the .html extensions from your URL.

    # November 12, 2011 at 8:59 pm

    @joelmb What if you have a .php file and a .html files in the same directory? How can you use the same .htaccess file?

    # November 13, 2011 at 5:25 pm

    RewriteRule ^([^/]+).php/(.*)$ /$1/$2 [NE,R=301,L,NC]
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.