Jump to content


Tutorial info

  • Added on: Nov 18 2011 09:43 AM
  • Date Updated: Nov 18 2011 10:50 AM
  • Views: 400


* * * * *
1 Ratings

How to Redirect all pages to index.html

This is ideal if you need to temporarily redirect all website URLs to a certain page.

Posted by EchelonOne on Nov 18 2011 09:43 AM
In your .htaccess file simply add this RegEx code. This will redirect ALL urls to an index.html file, unless you specify another file. In wordpress you will find this code, which we need to change slightly.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>

So, we need to modify this code rewrite conditions and change the rule. To do this we comment out the lines, so there's no need to delete them. Now, your code should look like this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / 
#RewriteCond %{REQUEST_FILENAME} !-f 
#RewriteCond %{REQUEST_FILENAME} !-d 
#RewriteRule . /index.php [L] 
</IfModule>

Now, add this line underneath to send all page requests to your custom index.html page.

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

Once you have completed changes to your websites files, just remove the rewrite rule above and undo the hashed lines.
Any questions feel free to ask!
Powered by Tutorials 1.3.1 © 2012, by Michael McCune