简体   繁体   English

Mod_rewrite-除特定页面外,拒绝访问

[英]Mod_rewrite - deny access except specific pages

Have a rewrite rule that redirects anyone not in the office to a holding page. 制定重写规则,将不在办公室的任何人重定向到保留页面。

RewriteEngine On

RewriteCond %{REMOTE_ADDR} !^x\.x\.x\.x$
RewriteRule . holdingpage.html

RewriteCond %{REMOTE_ADDR} ^x\.x\.x\.x$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [NC,L] 

I need allow google to access its google verification file: https://www.example.com/google23423423463.html 我需要允许Google访问其Google验证文件: https : //www.example.com/google23423423463.html

Is there a way to add a rewrite to allow anyone not in the office to access this page, as well as be redirected to the holding page when accessing any other page? 有没有一种方法可以添加重写以允许不在办公室的任何人访问此页面,以及在访问任何其他页面时重定向到保留页面?

Many thanks, 非常感谢,

Yes sure you can do: 是的,您可以做到:

RewriteEngine On

# If request is for special page, skip all rules below
RewriteRule ^google23423423463\.html$ - [L]

RewriteCond %{REMOTE_ADDR} !^x\.x\.x\.x$
RewriteRule . holdingpage.html [L]

RewriteCond %{REMOTE_ADDR} ^x\.x\.x\.x$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM