开发者

Site Down For Maintenance

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 开发者_JAVA技巧each subdirectory something like...

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


This should work:

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


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜