使用HTACCESS将我的IP重定向到网站的另一个部分


Redirect my IP to another section of the site using HTACCESS

我正试图将我的所有流量重定向到网站的不同部分,并将我的IP重定向到开发部分,有人能告诉我我做错了什么吗?

RewriteCond %{REMOTE_ADDR} ==My IP
RewriteRule ^([^/'.]+)/?$ dev/index.php?page=$1 [L]

如果我转到mysite.com/index,它会转到404。如果我删除了我的IP的rewritecond,那么它就工作了。

您可以这样使用该规则:

RewriteCond %{REMOTE_ADDR} =11.22.33.44
RewriteRule ^([^/.]+)/?$ dev/index.php?page=$1 [L,QSA]
RewriteCond %{REMOTE_ADDR} =11.22.33.44
RewriteRule ^([^/.]+)/([^/.]+)/?$ dev/index.php?page=$1&action=$2 [L,QSA]

试试这个:

重写规则^([^/.]+)/?$/dev/index.php?page=$1[L]