.htaccess 重定向到除我之外的所有 IP
问题描述:
基本上,我正在尝试在网站的前端工作,但如果您愿意,我希望除我自己以外的其他所有人都被重定向到构建页面.我目前有:
Basically, I am trying to work on the front end of a website, but I would like everyone else but myself to be redirected to a construction page if you like. I currently have:
redirect 301 /index.php http://www.domain.com/construction.php
虽然这有效,但效果很好,我希望自己仍然能够看到实时站点,是否可以排除除我的 IP 之外的所有人?
While this works, it works to well, I would like to be able to still see the live site myself, is it possible to exclude everyone but my IP?
再次感谢.
答
你可以用 mod_rewrite 做到这一点
You could do it with mod_rewrite
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !=123.45.67.89
RewriteRule index.php$ /construction.php [R=301,L]