htaccess条件重写?

时间:2012-10-01 02:07:09

标签: .htaccess mod-rewrite

我正在尝试阻止对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]

1 个答案:

答案 0 :(得分:0)

这有用吗?

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