我使用cakePHP,它使用以下重写:
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
我现在需要添加一个IP过滤器,它提供对路径的单个IP访问(其他人获得403 Forbidden)。我是这样做的:
RewriteCond %{REMOTE_ADDR} !^12.345.67.89$
RewriteRule ^/the-path/ - [F,L]
但是我怎样才能把这些组合起来呢?如果我这样做,IP过滤器似乎会被忽略:
RewriteCond %{REMOTE_ADDR} !^12.345.67.89$
RewriteRule ^/the-path/ - [F,L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
去掉RewriteRule
模式的斜杠,简化规则:
RewriteCond %{REMOTE_ADDR} !^12.345.67.89$
RewriteRule ^the-path(/.*)?$ - [F,L]
RewriteRule (.*) app/webroot/$1 [L]