Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .htaccess to remove file extensions

    Hello,

    I just built my first website in dreamweaver for one of my classes last semester. I hosted my site through godaddy, and the url is www.nmariephoto.com


    Anyway, I would like to be able to remove the .html from each page so it's just /contact or /about etc...I've read several articles saying you use htaccess to remove extensions, but I must be doing something wrong because I can't seem to make it work.

    I made a document in notepad .htaccess and used this code which was recommended.

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^(.*)$ $1.html
    I'm using Filezilla to upload my files. Do I need to create new directories and put the .htaccess code in each directory? I think I tried to do that last night but then the page said it was missing when I went to look online.

    I appreciate any help! Pretty new to this and just trying to get a better understanding. Thanks.

  • #2
    New Coder
    Join Date
    Dec 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually having a few issues at the moment, so my site may not show up correctly! fixing now

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    88
    Thanks
    4
    Thanked 26 Times in 26 Posts
    This should do it. If you request www.mysite.null/test it will redirect to www.mysite.null/test.html


    Code:
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.+)$ $1.html [L,QSA]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •