如何从htaccess重定向中排除页面?

时间:2015-06-27 02:16:17

标签: .htaccess redirect

我有一个htaccess维护重定向,

RewriteCond %{REQUEST_URI} !^/maintenance\.php$
RewriteRule ^(.*)$ http://example.net/maintenance.php [R=307,L]

它有效 - 但如何从重定向中排除页面,以便我可以访问该页面以查看维护期间发生了什么?

2 个答案:

答案 0 :(得分:2)

只需使用正则表达式替换在重写条件中添加更多pasge:

RewriteCond %{REQUEST_URI} !^/(maintenance\.php|page\.php)$
RewriteRule ^ /maintenance.php [R=307,L]

现在page.php将从此规则中排除。

答案 1 :(得分:0)

您可以添加不会发生重定向的IP地址,请参阅下面的示例。将AA.BB.CC.DD替换为您的实际IP地址。

RewriteCond %{REQUEST_URI} !^/maintenance\.php$
RewriteCond %{REMOTE_ADDR} !=AA.BB.CC.DD
RewriteRule ^(.*)$ http://example.net/maintenance.php [R=307,L]
相关问题