Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I need to force all requests regardless of what they are to index.html. Unfortunately everything I have tried has not worked properly.

The following seems to me like it should work but it doesn't. My understanding is that it is saying for anything that doesn't end in /index.html to actually request the index.html file.

Redirect 302 !^/index.html

Any help/clarification would be greatly appreciated.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Using an .htaccess on the root folder this should do the job:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteRule . index.html [R=302,L]

The condition and rule is that if the request does not match index.html it will redirect whatever to it

share|improve this answer
Thank you Prix, that worked perfectly! – Daemon of Chaos Oct 7 '10 at 14:25
Would you happen to know if it is possible to do this for all IPs except specified ones? – Daemon of Chaos Oct 7 '10 at 15:28
You mean ip from those accessing the website or ips within the server ? update your question with an example of what you are looking for and i will check it out. – Prix Oct 7 '10 at 20:22
Is there any way to make this work just for requests made on a subfolder of the root dir? SO that requesting triggers the redirect while doesn't. – StepTNT Apr 3 '13 at 9:06

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.