views:

39

answers:

1

This is my httpd.conf file for my http://old.example.com :

RewriteEngine on
RewriteBase /
RewriteRule ^login$  http://another.example.com/login   [L]

The problem is that although I can redirect to http://another.example.com/login, but the location bar is still showing http://old.example.com/login.

Any idea how to fix this?

+5  A: 

If you’re using mod_rewrite in the server or virtual host configuration, you always need to specify the full URL path in your patterns:

RewriteRule ^/login$ http://another.example.com/login [L,R]

Only when used in the per-directory context like in a .htaccess file you just need to specify the relative URL path without the contextual path prefix.

And also try an explicit redirect by setting the R flag:

RewriteRule ^/login$ http://another.example.com/login [L,R]

With that you can also specify a status code:

RewriteRule ^/login$ http://another.example.com/login [L,R=301]
Gumbo