Anthony Russo
Anthony Russo

Reputation: 931

.htaccess remove .html

I realize there is another post about how to remove .html but it is not working for me so I am trying to understand a little better how this process works.

I have fatcow for my hosting service. I downloaded the .htaccess from fatcow and it downloaded at a .htm file. I inserted this code via notepad.

 <IfModule mod_rewrite.c>

  Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
  RewriteRule ^(.*)$ $1/ [R=301,L]

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.html -f
  RewriteRule ^([^\.]+)/$ $1.html 

 </IfModule>

I saved the file as .htaccess and uploaded it to my root folder on fatcow. It is now saved in my root folder as .htaccess.txt

What am I doing wrong here to where this is not working?

UPDATE:

I renamed the .htaccess.txt to .htaccess via FTP client. It shows up at .htaccess now but it is still not removing the .html from my urls.

Upvotes: 0

Views: 985

Answers (1)

It should be saved as .htaccess, not .htaccess.txt.

It might be named this way because you created the file on Windows. If this is the case, you have two options:

Upload, then rename

Once the file is uploaded to the server, you can most likely rename the file to have the correct name.

Rename, then upload

You can rename it by doing the following in the Command Prompt:

cd C:\Directory\With\File\In\It
rename .htaccess.txt .htaccess

Once that is done, it should be named .htaccess properly, and can be uploaded.

Upvotes: 4

Related Questions