2014-01-14 127 views
0

基本重寫規則不起作用,我不知道爲什麼。這裏是我的hanalulu.confApache重寫規則不起作用

<VirtualHost *:80> 

ServerName hanalulu.localhost 
DocumentRoot /var/www/hanalulu/public 
DirectoryIndex index.php 

<Directory /> 
    AllowOverride all 
    Order Deny,Allow 
    Deny from all 
    Allow from 127.0.0.1 
</Directory> 

RewriteEngine on 
RewriteRule ^a.html$ b.html 

</VirtualHost> 

後,我在hosts文件添加一個額外的線上,並通過sudo a2ensite啓用站點。重新啓動的Web服務器:hanalulu.localhost/a.html請求a.html而不是b.html

什麼問題?

回答

5

我認爲你需要在你的路徑斜槓,並在重寫規則的標誌,試試這個:

<VirtualHost *:80> 

ServerName hanalulu.localhost 
DocumentRoot /var/www/hanalulu/public 
DirectoryIndex index.php 

<Directory /> 
    AllowOverride all 
    Order Deny,Allow 
    Deny from all 
    Allow from 127.0.0.1 
</Directory> 

RewriteEngine on 
RewriteRule ^/a.html$ /b.html [R,L] 

</VirtualHost> 
+0

ü救了我的一天,朋友:) +1 – sitilge