Removing .html and index.html from URL

Posted by James Turner on Pro Webmasters See other posts from Pro Webmasters or by James Turner
Published on 2012-07-05T19:46:52Z Indexed on 2012/07/05 21:24 UTC
Read the original article Hit count: 911

Filed under:
|
|

I'm having some problems trying to

  1. Remove the .html extension from URLs
  2. Removing 'index.html' from an URL

1) To remove the extension I have tried using this in my htaccess file.

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

However when I click links in my HTML such as <a href="abcde.html"></a> it doesn't remove the .html from the URL and I am left with www.website.com/abcde.html

2) I tried using this to remove the index.html

RewriteCond %{THE_REQUEST} \/index\.(php|html)\ HTTP [NC]
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]

But when I load an index.html file on my server, my URL looks something like this

www.website.com/folder//

I am left with an extra / at the end.

Can anyone help me out?

© Pro Webmasters or respective owner

Related posts about htaccess

Related posts about url