views:

33

answers:

2

I have a site arranged as follows with subdomains as subdirectories:

/ [webroot]
/subdomain1/
/subdomain2/

I'd like to create an htaccess file that rewrites all accessed files to maintenance.php w/ 503 message, but I'm not sure why the following does not catch the subdirectories?

RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444$ 
RewriteCond %{REQUEST_URI} !^/maintenance\.php$
RewriteRule ^(.*)$ /maintenance.php [L]

Do I have to call out each subdirectory something like...

RewriteRule ^/subdirectory1(.*)$ /maintenance.php [L]
RewriteRule ^/subdirectory2(.*)$ /maintenance.php [L]
A: 

This should work:

RewriteEngine On
RewriteCond %{REMOTE_HOST} !^111\.222\.333\.444
RewriteCond %{REQUEST_URI} !/maintenance.php$
RewriteRule $ /maintenance.php [L]
zilverdistel
A: 

If you have additional htaccess files in your subdirectories, you have to watch for changes after you remove that file. If htacess controls rewrite, you may receive 404 errors when you view those pages.

I was expecting to see the maintenance page, not realizing I needed to have a different ip address according to the following code:

This code allows your ip to view the site and no one else:

RewriteEngine On
RewriteBase /

#ip is not your ip. Change ip to see maintenance page
RewriteCond %{REMOTE_ADDR} !^111\.222\.333\.444$

#requests made not to maintenance.php ... 
RewriteCond %{REQUEST_URI} !^/maintenance\.php$

#rewrite to maintenance.php
RewriteRule ^(.*)$ /maintenance.php [L]
rrrfusco