Forum Moderators: open

Message Too Old, No Replies

Google friendly redirects of many URLs.

mod_rewrite is hard, mod_rewrite from a DB harder.

         

killroy

2:38 pm on Apr 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a directory site that ahs a large number of categories. I am in the process of creatign a super site that inclodes that database and many more.

To kick start it I linked to some of its pages like this:

oldsite/cat1/subcat1 -> newsite/oldsitecountry/cat1/subcat1
oldsite/cat2/subcat2 -> newsite/oldsitecountry/cat2/subcat2

well enough, only I made a mistace to link from a city index as well. I removed it within hours but google had already picked up many of hte links. They went like this:

oldsite/city1/cat1/subcat1 -> newsite/oldsitecountry/city1/cat1/subcat1
oldsite/city2/cat2/subcat2 -> newsite/oldsitecountry/city2/cat2/subcat2

To prevent the pages to show garbage I have temporarily doen met refreshes from
newsite/oldsitecountry/city1/cat1/subcat1
to
newsite/oldsitecountry/cat1/subcat1

now I'd like to take city1 through cityxxxx fomr a database and do a mod_rewrite for these URLs, a 301 for a month and then remove it again to put google back on its track and avoid any penalisations for bad 404 links.

How would that work?

S. N.

Brett_Tabke

9:42 pm on Apr 6, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Ya, 301 is your best best bet. Make sure to double check your server headers to see that indeed you are kicking out the 301.

killroy

1:39 am on Apr 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is, I don't really want to add 200-800 redirects in my config files. Isn't there a better way? I could easily do it form withinthe script, but I don'T know how to spit out the 301, i.e. how to do an unparsed header exec on Apache.

SN

speda1

1:55 am on Apr 7, 2003 (gmt 0)

10+ Year Member



You could do it with mod rewrite. You might have to tweak it a bit.

RewriteRule /(.*) [newsite.com...] [R=301,L]

jdMorgan

3:09 am on Apr 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



killroy,

From what you've posted, I couldn't figure out what you need to accomplish with 200-800 rewrites. But, just as an example of how to do multiple redirects with one RewriteRule, here's a rule to replace your meta-refreshes, described as:

newsite/oldsitecountry/city1/cat1/subcat1
to
newsite/oldsitecountry/cat1/subcat1

RewriteRule ^/newsite/oldsitecountry/city1/([^/]*)/(.*) /newsite/oldsitecountry/$1/$2 [R=301,L]

As shown, it's for use in httpd.conf. For .htaccess use, change "^/newsite" to "^newsite".

More info: Introduction to mod_rewrite [webmasterworld.com]

HTH,
Jim