2014-01-14 131 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