的.htaccess mod_rewrite的基于IP的重定向:如何将所有的流量重定向到一个特定的子目录,除了我的IP? [英] .htaccess mod_rewrite IP-based redirect: how to redirect all traffic to a specific subdirectory, except my IP?
本文介绍了的.htaccess mod_rewrite的基于IP的重定向:如何将所有的流量重定向到一个特定的子目录,除了我的IP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望我的观众只有到我的网站(博客)的特定部分的访问。如果他们尝试访问该网站的其他领域,我希望他们重定向到博客节。
I want my visitors to have access only to a specific part of my website (blog). If they try to access other areas of the website, I'd like them redirected to the blog section.
我也希望这适用于每一个人,除了我的IP地址。
I also want this to apply to everyone except to my IP address.
因此,结构如下:
允许mysite.com/blog //游客进入
mysite.com // redirect to mysite.com/blog
mysite.com/forum // redirect to mysite.com/blog
mysite.com/tools // redirect to mysite.com/blog
etc...
你对如何通过的.htaccess的mod_rewrite做到这一点建议?
Do you have a suggestion on how to do this via .htaccess mod_rewrite?
推荐答案
您应该能够重定向为以下内容:
You should be able to redirect with the following:
RewriteCond %{REMOTE_HOST} !^123\.456\.789
RewriteCond %{REQUEST_URI} !^/blog/?
RewriteCond %{REQUEST_URI} /(.*)$
RewriteRule (.*) /blog [R=301,L]
这篇关于的.htaccess mod_rewrite的基于IP的重定向:如何将所有的流量重定向到一个特定的子目录,除了我的IP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文