由于某种原因,我无法让 mod_rewrite 工作。我已启用它,它在 phpinfo() 下可见,并且我已启用适当的权限。发生了什么?
000-默认:
<VirtualHost *:80>
ServerAdmin ****@gmail.com
ServerName ****.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
这是我用于检查的重写规则......
RewriteEngine on
RewriteRule ^index.php?act=(.*)&p=(.*)$ site/$1/$2.html
有人能发现任何异常吗?
答案1
您没有提到的一件事是 中的模块/etc/apache2/mods-available/rewrite.load
,它启用了重写引擎。如果您还没有这样做,您需要在目录中添加一个链接/etc/apache2/mods-enabled
;从目录/etc/apache2/mods-enabled
,输入ln -s ../mods-available/rewrite.load
以创建指向此目录的符号链接。
您也可以使用“sudo a2enmod rewrite”