andy
andy

Reputation: 2754

remove .html with htaccess

I'm using my htaccess file to try to remove .html (and other if I need to) file extensions from my web URL's.

The problem is it doesn't seem to work unless I go through my links in the site and manually remove .html from all of them (which makes testing the site locally quite annoying and I'm not sure if I'm supposed to remove the .html file extension).

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

This works if a user types in www.mysite.com/about instead of www.mysite.com/about.html, except when clicking through the links of my site it still adds the extension?

What's the best way to go about removing the .html, absolute links on my site with http://www.mysite.com/about etc or should I remove the extension and just have paths like ../about instead of ../about.html?

Upvotes: 1

Views: 5695

Answers (1)

Julien
Julien

Reputation: 3529

.htaccess file does not change your code so if you put the extension in your page (for links), you must remove it.

Upvotes: 2

Related Questions