基本的重写规则不起作用,我不明白为什么。这是我的 hanalulu.conf :
<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
启用了该网站。重新启动的网络服务器:hanalulu.localhost/a.html
请求a.html
而不是b.html
。
有什么问题?
答案 0 :(得分:5)
我认为你需要路径中的斜杠和RewriteRule上的标志,试试这个:
<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>