[clue-tech] Simple (?) mod_rewrite problem

Angelo Bertolli angelo at freeshell.org
Sun Nov 19 15:26:19 MST 2006


Jed S. Baer wrote:
> In the process of moving to another web host, I'm at the stage of being
> ready to wipe out the blog at the old host, but I'd like to redirect
> requests to the new digs for as long as the account at the old site stays
> active. So, I'm trying to use mod_rewrite from an .htaccess file, which
> looks pretty simple for my purposes. So, here's the .htaccess file.
>
> Options FollowSymLinks
> RewriteEngine On
> RewriteRule .*index\.php\?id=P([0-9]+)
> http://freedomsight.net/index.php?p=$1 [R=permanent,L]
>
> Where the URL to be rewritten is of the form:
> http://s88369986.onlinehome.us/freedomsight/index.php?id=P1928
> and all I need to do is capture the trailing digits, to plug into the new
> URL.
>
> Reading the Apache mod_rewrite docs and URL rewriting guide, this looks
> (apparently) deceptively simple. For example, what I need to do seems, to
> me, to be quite similar to the
> http://httpd.apache.org/docs/trunk/rewrite/rewrite_guide.html "Move
> Homedirs to Different Webserver" example.
>
> I've tried many variations on the pattern, including using '%3F' for the
> '?' in case the URL at that point is URL encoded. But I'm beginning to
> think that the "URL" (uh, so to speak) which the pattern is used against
> is just the path portion of the URL, and doesn't include paramters. So,
> I'm continuing to read, but if anyone wants to jump in with some advice,
> feel free.
>   
I know this is kind of late, but since both sites use index.php?id=P for
the first part, why bother trying to pull out JUST the number and place
it back in the new URL?  Why not something simple like:

RewriteRule ^/freedomsight/(.*)$ http://freedomsight.net/$1 [R=301,L]





More information about the clue-tech mailing list