.htaccess 在我的系统中不起作用。我做了以下几件事。
在 httpd.conf 文件中包含 mod_rewrite.so 文件
并将所有
Allowoverride None
更改为 Allowoverride All
并已重新启动服务器。但它仍然不起作用。有人可以帮助我吗?
这是我的.htaccess 文件
RewriteEngine On
Options +FollowSymLinks
RewriteRule ^test\.html http://www.google.com/? [R=301,L]
以下是它可能不起作用的原因之一:
您应该在服务器的虚拟主机文件中添加以下配置指令,以允许 DocumentRoot 目录中的 .htaccess 文件。如果不添加以下行,.htaccess 文件将无法工作:
</VirtualHost>
<Directory /var/www/test.com/public_html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
参见 https://www.redhat.com/sysadmin/beginners-guide-redirects-htaccess