0

Our hosts are currently having problems with PHP, so I've had to set up a static index.html page to advice visitors to our website. Can anybody please tell me what I need to put in .htaccess so that every address in the domain is redirected to the home page for now?

Thanks.

Here is the final answer, slightly amended from the one supplied below to allow images, CSS, etc to still be downloaded as that is referenced by my static page.

Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

RewriteRule !\.(js|ico|gif|jpg|png|css|html|swf|mp3|wav)$ /error.html [NC,L]
David Gard
  • 11,225
  • 36
  • 115
  • 227

2 Answers2

2

put this is .htaccess file in your DocumentRoot.

I presume that path of index.html is </path/to/your/DocumentRoot>/index.html

Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

RewriteRule ^ /index.html [L]
ThinkingMonkey
  • 12,539
  • 13
  • 57
  • 81
  • Thank you, that is a pretty much there. This does also seem to be redirecting any content that is downloaded by the page (logos, stylesheets, etc) though, is it meant to do that? See our website - [link]http://www.dynedrewett.com - for an example. According to Firebug, the page is not even attempting to download the content, but like I say, going to one of those links redirects to the error.html (not index.html as I originally said) page. Thanks. – David Gard Feb 15 '12 at 11:50
  • In fact, please ignore the bit about content not being downloaded. I've just checked another of our sites with the same host that doesn't have these rules applied to it yet and the same thing is happening, so it's likely down to their problems. Thanks. – David Gard Feb 15 '12 at 11:53
1

Create a .htaccess file in your app root folder with the following:
This way css, js, etc files are not redirected.

RewriteEngine On
RewriteBase /

#skip existing files or directories
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d
#everything else goes to index.html
RewriteRule ^ index.php?request=%{THE_REQUEST} [L]

Taken from here

Community
  • 1
  • 1
Slipstream
  • 13,455
  • 3
  • 59
  • 45