3

Trying to remove .html extensions from the site using .htaccess. So for example: www.mysite.com/charts.html would become www.mysite.com/charts

The following script is in the .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\.html$ /$1 [L,R=301]

But when the url without the .html extension is entered in the browser, it shows a 403 Forbidden error. Any help would be appreciated.

RMX
  • 313
  • 5
  • 15
  • Would we have to create a conf file? Looked around and don't see a conf file anywhere in our server files. – RMX May 20 '12 at 21:25

1 Answers1

7

I found this solution elsewhere:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html

sources: 1) http://www.catswhocode.com/blog/10-useful-htaccess-snippets-to-have-in-your-toolbox 2) http://eisabainyo.net/weblog/2007/08/19/removing-file-extension-via-htaccess/

Cosades
  • 331
  • 3
  • 9