基本的重写规则不起作用,我不知道为什么.这是我的hanalulu.conf:
ServerName hanalulu.localhost DocumentRoot /var/www/hanalulu/public DirectoryIndex index.php AllowOverride all Order Deny,Allow Deny from all Allow from 127.0.0.1 RewriteEngine on RewriteRule ^a.html$ b.html
我在hosts
文件中添加了一个额外的行并通过后启用了该站点sudo a2ensite
.重新启动的Web服务器:hanalulu.localhost/a.html
请求a.html
而不是b.html
.
问题是什么?
我想你需要你的路径中的斜杠和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>