httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Mearns <>
Subject Re: [users@httpd] mod_rewrite: moved directory
Date Wed, 18 Mar 2009 12:55:26 GMT
On Wed, Mar 18, 2009 at 8:04 AM, Florent Georges <> wrote:
>  Hi,
>  I moved one directory one level up in the hierarchy of web pages,
> let's say:
>    from:
>    to:
>  I try to use mod_rewrite to handle this move, and redirect users
> for a while to the new location.  I've read the URL Rewriting Guide
> at <>, from
> which I thought the following should handle this case:
>    RewriteEngine  on
>    RewriteRule    ^/parent/child(.*) /child$1 [R]
>  But it does not.  When I try to access the old location, I simlpy
> get a 404.
>  Is there a way to handle this problem?  With mod_rewrite or any
> other "standard" module.
>  Regards,
> --
> Florent Georges

Mod_rewrite is a perfectly good way to solve this problem. I'm not
sure off hand why it's not working, but your first step in debugging
this should be to turn on your rewrite logs and monitor them when you
try to access the old address. Check back in the documentation for how
to turn them on and where they live.

Once you resolve the issue, I would recommend using [R=301] instead of
just [R] for this rule, assuming that the move is permanent. This will
inform clients that from now on, they should use the new address
instead of continuing to use the old one, which will reduce connection
time and network traffic. A 301 will also help you if you're old pages
are known by any search engines because it will tell them that any
stats or ranking they've come up with for the old pages should be
transferred to the new ones, instead of starting from scratch.

Anyway, check your rewrite logs and if you're still having problems,
get back to us with the actual rewrite rule copied directly from your
config file: using phony urls (I'm assuming parent and child are
phony) is good for illustration, but not for debugging.

Hope that helps,

Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from:

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message