重定向一个特定的IP地址到我的主页用的.htaccess的专页 [英] Redirect a specific IP address to a special page of my homepage with .htaccess
本文介绍了重定向一个特定的IP地址到我的主页用的.htaccess的专页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何使用的.htaccess到特定IP地址的访问者转发到我的网页服务器上?
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
注:我的网站包含的.htm,html和.PHP页
Note: My website consists of .htm, html and .php pages.
您的帮助将是非常美联社preciated。
Your help would be very much appreciated.
推荐答案
添加一个条件的没有的重写,当你已经在specialpage:
Add a condition to not rewrite when you're already at specialpage:
RewriteCond %{REMOTE_ADDR} ^123\.\123\.123\.123$
RewriteCond %{REQUEST_URI} !/specialpage.php
RewriteRule ^(.*)$ /specialpage.php [R,L]
这篇关于重定向一个特定的IP地址到我的主页用的.htaccess的专页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文