我试图阻止对 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
我只是不明白为什么这行不通。
其余的 mod 重写工作正常:
#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]