Re: mod_rewrite: moved directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 18, 2009 at 8:04 AM, Florent Georges <lists@xxxxxxxxxxxx> wrote:
>
>  Hi,
>
>  I moved one directory one level up in the hierarchy of web pages,
> let's say:
>
>    from: http://www.example.com/parent/child/
>    to:   http://www.example.com/child/
>
>  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 <http://httpd.apache.org/docs/2.0/misc/rewriteguide.html>, 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
> http://www.fgeorges.org/


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

-- 
Feel free to contact me using PGP Encryption:
Key Id: 0x3AA70848
Available from: http://pgp.mit.edu/

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux