更新 - 更清楚地了解了我所遇到的mod_rewrite故障。在Apache中,我在配置文件中进行了以下设置:
LoadModule rewrite_module modules/mod_rewrite.so
DocumentRoot "C:/mywebdev/apache/www"
RewriteEngine On
Include conf/extra/httpd-vhosts.conf
<Directory "C:/mywebdev/apache/www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
我的vhosts config
中有以下内容 <Directory "C:/mywebdev/apache/www/test">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
<Directory "C:/mywebdev/apache/www/test/.htaccess">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:/mywebdev/apache/www/test
ServerName www.test.me
ServerAlias test.me *.test.me
LoadModule rewrite_module modules/mod_rewrite.so
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/library/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
</VirtualHost>
在.htaccess文件中我有:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/library/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我知道这太过分了,但这只是为了证明无论我做什么都不行。我检查了mod_rewrite.so是否在modules文件夹中,它就在那里。该模块不适用于此尝试或我尝试使用的任何其他mod_rewrite规则。从我所读到的,这应该是有效的。提前感谢您的任何帮助。
答案 0 :(得分:1)
我不确定,但是,内容:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/library/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
应该进入该文件夹中的.htaccess
文件。如果我错了,请纠正我。
答案 1 :(得分:1)
在此
之间插入重写代码<IfModule mod_rewrite.c>CODE</IfModule>