htAccess 有条件重写



我正在尝试阻止对CodeIgniter控制器函数的公共访问,但这个.htaccess规则不起作用:

#Block External Access to create pdfs function
RewriteCond %{REMOTE_ADDR} !^127.0.0.0
RewriteCond %{REMOTE_ADDR} !^x.x.x.x
RewriteCond %{REQUEST_URI} ^/applicationForm/createPDF
RewriteRule ^(.*)$ index.php/$1 [F,L]

注意 x 已替换为服务器公共 IP

我只是不明白为什么这行不通。

其余的模组重写工作正常:

#Removes access to the system folder by users.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

这行得通吗?

RewriteCond %{REMOTE_ADDR} !^127.0.0.0
RewriteCond %{REMOTE_ADDR} !^x.x.x.x
RewriteRule ^/?applicationForm/createPDF /index.php/$1 [F,L]

最新更新