I want to redirect "http://localhost/b.html" --> "http://localhost/a.html" I tried RewriteRule for that. But somehow it is not working for me.
I am using apache2 and my httpd.conf contains:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule ^/b.html$ http://localhost/a.html
When I tri "http://localhost/a.html" It shows me the web page. But when I triend "http://localhost/b.html" apache2/error_log says "file does not exist: b.html" Does any setting missing to enable rewrite_module?
Have you checked whether in your Apache configuration file (most likely httpd.conf) the directive for the Alias or VirtualHost section:
I had the same problem of modrewrite not working because I had it off:
Good luck.
It works now. Had to do two things:
Change "AllowOverride None" in /etc/apache2/sites-available/default to "AllowOverride All".
Put the rewrite rule in /var/www/.htaccess instead of httpd.conf
I am not sure why it does not works in httpd.conf. But it works after doing the above two things.
Do you have it inside the virtualhost section?
The problem is in your RewriteRule. this should work:
the rule match ((this works in .htaccess, but not in server config)^b.html$
) must not include the starting slash.[L]
eave processing (no more rules will be processed)