我尝试重定向用户,如果他们有特定的IP,如果访问的路径是" admin",请使用以下行但不起作用(使用任何路由重定向):
RewriteCond %{REMOTE_ADDR} !^(123\.123\.123\.123|123\.123\.123\.123)
RewriteCond %{REQUEST_URI} !/admin$
RewriteRule !^maintenance/ / [R=302,L]
我使用laravel htaccess完整代码是:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front UserController...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REMOTE_ADDR} !^(123\.123\.123\.123|123\.123\.123\.123)
RewriteCond %{REQUEST_URI} !+/admin$
RewriteRule !^maintenance/ / [R=302,L]
</IfModule>
有什么想法吗?