Knowledgebase

How can I redirect everything to index.html using mod_rewrite?

Posted by jalapeno55, 08-27-2008, 12:55 PM
How can I redirect everything to index.html using mod_rewrite in a .htaccess file? IE. if someone goes to domain.com/contactus.html, it will go to domain.com/index.html and if someone goes to domain.com/images/index.html, it will goto domain.com/index.html domain.com is the same domain in all instances. Thanks in advance!

Posted by livechatr, 08-28-2008, 02:01 AM
Try this: The second rule does the job, it reads like "redirect any page (.+) to index.html... permanently (R=301)". But the first rule is necessary to prevent the infinite loop of redirecting index.html to itself. Last edited by livechatr; 08-28-2008 at 02:03 AM. Reason: added explanation

Posted by Xous, 08-28-2008, 03:28 AM
Don't forget to add exceptions for any images or other resource files such has css files that your index page needs as with the above redirect they will not be exempted.

Posted by livechatr, 08-28-2008, 04:54 AM
Ah, yes. Xous is absolutely right. If ALL of your pages end with .html, then you can try this: Hope this helps.



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Dinix down again? (Views: 585)
Short and sweet (Views: 545)


Language:

Client Login

Email

Password

Remember Me

Search