2011-11-03 127 views
1

我想將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> 
+0

你的規則對我來說工作得很好。請參閱下面的@ nfechner的答案,瞭解可能的缺失配置。 – Perception

回答

2

你可能缺少<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