使用 .htaccess 将特定 IP 地址重定向到我主页的特殊页面
如何使用 .htaccess 将特定 IP 地址的访问者转发到我的服务器上的网页?
这个例子会导致无限循环:
RewriteCond %{REMOTE_ADDR} ^123\.\123\.123\.123$
RewriteRule ^(.*)$ /specialpage.php [R,L]
我在网上找到了这个,但它不起作用:
SetEnvIf REMOTE_ADDR 123.123.123.123 REDIR="redir"
RewriteCond %{REDIR} redir
RewriteRule ^(.*)$ /specialpage.php
注意:我的网站由 .htm、html 和 .php 页面组成。
非常感谢您的帮助。
How can I use .htaccess to forward a visitor of a specific IP address to a webpage on my server?
This example causes an infinite loop:
RewriteCond %{REMOTE_ADDR} ^123\.\123\.123\.123$
RewriteRule ^(.*)$ /specialpage.php [R,L]
I found this on the web but it just does not work:
SetEnvIf REMOTE_ADDR 123.123.123.123 REDIR="redir"
RewriteCond %{REDIR} redir
RewriteRule ^(.*)$ /specialpage.php
Note: My website consists of .htm, html and .php pages.
Your help would be very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加一个条件,以便在您已经处于特殊页面时不重写:
Add a condition to not rewrite when you're already at specialpage:
刚刚找到解决方案:
谢谢您的帮助!
Just figured out the solution:
Thank you for your help!