Apache http服务器重写URL失败
问题描述:
我想将http://www.example.com/index.htm
重定向到 本地文件:/home/admin/mf/htdocs/default.htm 如下配置httpd.conf中的apache服务器,但它不起作用,我的配置有任何问题 ?Apache http服务器重写URL失败
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /home/admin/mf/htdocs
RewriteEngine on
RewriteRule ^/index.htm /default.htm
</VirtualHost>
答
你可能缺少<Directory>
指令的文档根/home/admin/mf/htdocs
:
<Directory /home/admin/mf/htdocs>
Order allow,deny
Allow from all
<Directory>
欲了解更多信息,请参阅here。
+0
我尝试使用绝对路径将请求重新发送到本地文件也不起作用:RewriteRule ^/index.htm /home/admin/test/default.htm – codefarmer
+0
+1对此答案,我相信它是正确的一。 – Perception
你的规则对我来说工作得很好。请参阅下面的@ nfechner的答案,了解可能的缺失配置。 – Perception