Reputation: 71
Hi there quick question (regarding htaccess): I want to be able to have my website go down for maintenance easily.
I want everything to be forwarded to /maintenance/index.html except the root / home page. I tried the following:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^$ [NC] #Dont forward the root!
RewriteCond %{REQUEST_URI} !/maintenance/index.html$ [NC]
RewriteRule .* /maintenance/index.html [R=302,L]
However it didn't work. Going to my website example.com still forwarded to the maintenance page. Any ideas on what I'm doing wrong? I figure it must be the "!^$" or something.
Thanks a lot!
Upvotes: 1
Views: 781
Reputation: 784918
This should work:
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/maintenance/index\.html$ [NC]
RewriteRule ^.+$ /maintenance/index.html [R=302,L]
.+
will make sure that root page is not redirected.
Also make sure this rule is first rule.
Upvotes: 1