Jump to content
Killersites Forums

removing index.html from URL


Recommended Posts


1. In order to remove the index.html from my URLs I used the following code:

RewriteEngine on

RewriteCond %{THE_REQUEST} \/index\.(php|html)\ HTTP [NC]

RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]


While it works ok for the home page it results a 403 page for sub-directory index.html pages.

Could you kindly provide some solutions?


2. With the above-mentioned approach I can still see the URL with the index.html in the address bar for a few seconds before it is redirected. I can also see the complete link with the html extension when the mouse hovers on a link. Is there a way to hide that? Or, is there a better way to hide file extensions?



Link to comment
Share on other sites

If you set all your navigation/links to not have the index.html by applying the path to whatever root/folder like this:


Was: http://www.domain.com/index.html'>http://www.domain.com/index.html


Now: http://www.domain.com/



Was: http://www.domain.com/folder/index.html'>http://www.domain.com/folder/index.html


Now: http://www.domain.com/folder/


...then there would be no reason for redirects.

Link to comment
Share on other sites

  • 3 weeks later...

Sorry I came back to the issue again as I could not resolve it!

As newseed suggested I removed 'index.php' from the navigation links (For example, from /news/index.php to /news/) but I receive 403 error. How could I remove index.php from my URL ?(I would also like to remove it from the links so that when the mouse hovers the viewer does not see the 'index.php' part).


Link to comment
Share on other sites

If you have removed the index.php from the paths then naturally the former path will produce a 403. If you access the page via yourdomain.com/news/ and it still produces a 403 then you may need to check with your host to see what the default setting for index/default pages. Most host typcially are setup with index.html which may be the reason why you get the 403.


Keep in mind that the index.php file(s) still need to exist in their respective folders. And as for you links, remove all instances of index.php from it's path.


<a href="yourdomain.com/news/">Home</a>


As for you original post redirect that worked for the home page but not for the sub folders, just make a copy of each of the .htaccess file for each of the subfolder that requires the redirect.

Link to comment
Share on other sites


Certainly I have the index.php file in the folder. For example, in the folder for the file /news/index.php the link is to /news/. And of course the folder contains the file index.php file. I have configured to have index.php as the default page. Everything works fine as long as the links are made to the index file; for example, /news/index.php. If the link is made to /news/ then it does not work.


My original post says that 'redirect' to remove index.php/index.html works but still the links are basically to the index.php file. The extension of the URL can also be seen when the mouse hovers over the link.


For example, look at the following link:



Is there any other solution?



Link to comment
Share on other sites

If you remove your .htaccess file (or, at least the portions of the file that attempt to remove the index.html) I imagine that should fix the 403 error. If all of your links point to folders ("yoursite.com/news/" for example) rather than the index.html file, visitors shoudln't ever see the index.html portion, unless they type it in directly.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...