.htaccess - 将访问者重定向到网站的几个网址的正在 build 中的页面

标签 .htaccess redirect

我需要将我网站的几个特定网址上的访问者(少数 ip 仍然可以访问属于我们的访问权限)重定向到“正在 build ”页面。

我使用以下代码将完整的站点重定向到“正在 build ”页面,但这次我只需要重定向几个网址。

<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{REMOTE_ADDR} !^50\.40\.30\.20
 RewriteCond %{REMOTE_ADDR} !^100\.90\.80\.70
 RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
 RewriteRule .* /maintenance.html [R=302,L]
</IfModule>

假设我需要将 /example1//example2/ 页面重定向到“正在 build ”页面。我应该如何使用 .htaccess

做到这一点

最佳答案

您可以使用:

 RewriteEngine on

 RewriteCond %{REMOTE_ADDR} !^50\.40\.30\.20
 RewriteCond %{REMOTE_ADDR} !^100\.90\.80\.70
 RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
 RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
 RewriteRule ^(example1|example2) /maintenance.html [R=302,NC,L]

关于.htaccess - 将访问者重定向到网站的几个网址的正在 build 中的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40459360/

相关文章:

regex - Apache Rewrite 子域上的图像

apache - 未知目录的重写规则

php - 更改 Apache 默认索引文件

wordpress - 禁用所有父 htaccess

java - 如何使 Jersey 2 客户端在重定向时处理 cookie

redirect - Nginx 遵循重定向和反向代理最后位置

Apache rewriterule 将文件夹重定向到子文件夹而无需循环

apache - 如何将特定链接重定向到 https ://everything else to http://using . htaccess?

.htaccess - 将页面重定向到不同域下的同一页面

php - 无法访问子文件夹 | PHP框架