在我的Apache httpd.conf文件中,我在VirtualHost标签中有这个声明。
RewriteEngine On RewriteCond %{HTTP_HOST} !^www.shanestillwell.com$ [NC] RewriteRule ^(.*)$ http://www.shanestillwell.com/$1 [L,R=301]
而这个在我的.htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
我的httpd.conf的规则似乎被忽略。 .htaccess的规则是否清除了httpd.conf重写规则?
通常,您在目录中的.htaccess文件中的设置将覆盖httpd.conf文件设置。 你可以通过编辑你的httpd.conf文件来禁用这个效果,并改变下面一行
<Directory ...> AllowOverride all
至
<Directory ...> AllowOverride none
这将阻止.htaccess文件覆盖httpd.conf设置。 所以.htaccess文件中的设置将不起作用。
如果你有一个带有AllowOverride all的<Directory ...> ,那么你的.htaccess文件中的任何内容都将replace任何以前的规则。
它可以在您的httpd.conf或virtualhost ,只要它指向/或到您的域path。