sitilge
sitilge

Reputation: 3737

Apache rewrite rules not working

A basic rewrite rule is not working and I have no idea why. Here's my 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>

After I have added an extra line in hosts file and enabled the site via sudo a2ensite. Restarted web server: hanalulu.localhost/a.html requests a.html instead of b.html.

What is the problem?

Upvotes: 0

Views: 13747

Answers (1)

arco444
arco444

Reputation: 22861

I think you need the slashes in your path and the flags on the RewriteRule, try this:

<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>

Upvotes: 6

Related Questions