我在网上搜索了一段时间,找不到以下问题的正确答案:
我有一个工作。htaccess的codeigniter应用程序(index.php删除),看起来像这样:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www'.mydomain'.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
和/awstats/。Htaccess有以下规则:
Options +ExecCGI
AddHandler cgi-script pl
DirectoryIndex awstats.pl
AuthUserFile /home/MY_USER/domains/mydomain.com/public_html/awstats/.htpasswd
AuthType Basic
AuthName "AwStats Protection"
<LIMIT GET POST>
require valid-user
</LIMIT>
当我没有使用带密码保护的awstats时->一切都工作得很好。启用awstats的密码保护后-> CI显示404错误时,我试图访问mydomain/awstats。如何才能解决这个问题?
注意:mydomain.com/MY_USER只是为了这个例子:-)
而不是:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
你可以这样做:
RewriteCond $1 !^(index'.php|favicon'.ico|favicon'.png|crossdomain'.xml|robots'.txt|images|css|js|awstats)
RewriteRule ^(.*)$ /index.php/$1 [L]
所以你可以显式地授予访问任何不需要通过CI的前端控制器的东西。这是一种更安全的技术,但需要您显式地添加每个文件和目录(例如图像,css等)。