htaccess根据IP重定向
假设我的服务器如下所示:
/www/.htaccess
/www/index.php
/www/temp/index.php
我的个人 IP(不是服务器的!)是 127.0.0.1*
(* 好吧,这是不可能的,但为了论证......)
我想重定向(301/302)除了 /temp/index.php 的 IP 之外的每个人
我当前的代码如下所示:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
RewriteCond %{REQUEST_URI} !/temp/*$
RewriteRule \$ /temp/* [R=302,L]
但是我收到 500 错误。
Let's say my server looks like this:
/www/.htaccess
/www/index.php
/www/temp/index.php
And my personal IP (not the server's!) is 127.0.0.1*
(* ok, that's impossible, but for the sake of argument...)
I would like to redirect (301/302) everyone EXCEPT that IP to /temp/index.php
My current code looks like:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REMOTE_HOST} !^127\.0\.0\.1
RewriteCond %{REQUEST_URI} !/temp/*$
RewriteRule \$ /temp/* [R=302,L]
However I get a 500 error.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没关系,这些 htaccess 文件很难使用。我在主 index.php 文件中使用了一些 PHP 代码。
Never mind, these htaccess file are hard to work with. I used some PHP code in my main index.php file instead.