Mobile app version of vmapp.org
Login or Join
Sims2060225

: Using mod_rewrite to send all requests to a certain document I want to temporarily redirect all requests for a site to index.html, using Apache only. Is this mod_rewrite approach going to work,

@Sims2060225

Posted in: #Apache #ModRewrite

I want to temporarily redirect all requests for a site to index.html, using Apache only. Is this mod_rewrite approach going to work, and is it the right way to do it?

RewriteEngine on
RewriteRule ^.*$ /index.html [R]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

You need to use something like this I think:

RewriteRule !^/index.html$ /index.html [R=302]


Like pritaeas noted, you should use the 302 code to specify that the move is temporary. And you want to match everything but /index.html, otherwise you'll send the browser on an infinite redirect loop.

Also, if you have any images, stylesheets, JS files, or other resources that are in the same directory or subdirectory, you need to also make exceptions for those or turn the rewrite engine off in those directories.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme