.htaccess mod_rewrite 基于 IP 的重定向:如何将所有流量重定向到除我的 IP 之外的特定子目录?
我希望我的访问者只能访问我的网站(博客)的特定部分。如果他们尝试访问网站的其他区域,我希望他们重定向到博客部分。
我还希望这适用于除我的 IP 地址之外的所有人。
因此结构如下:
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 执行此操作有建议吗?
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.
I also want this to apply to everyone except to my IP address.
So the structure is as follows:
mysite.com/blog // visitor access allowed
mysite.com // redirect to mysite.com/blog
mysite.com/forum // redirect to mysite.com/blog
mysite.com/tools // redirect to mysite.com/blog
etc...
Do you have a suggestion on how to do this via .htaccess mod_rewrite?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该能够使用以下命令进行重定向:
You should be able to redirect with the following:
您应该创建一个处理特定重定向的页面,然后将您的 htaccess 文件编辑为如下所示:
rediret_page.html 可以有 js 或服务器端重定向来处理它们最终的位置,但这将迫使每个拥有不会通过处理重定向的特定页面访问您的 IP 地址。
You should create a page that handles the specific redirects, and then edit your htaccess file to be something like this:
The rediret_page.html can have either js or server-side redirection that handles where they end up, but it will force everyone who has not come on your IP address through a specific page that handles redirection.
只需将您的 IP 地址添加到..
Just add your IP Address in..