Forum Moderators: open

Message Too Old, No Replies

Condensing similiar 301's?

.htaccess redirect

         

keyplyr

6:50 pm on May 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have obsolete pages that I redirect to the index page now, all within same domain:

Redirect 301 /old_1.html [domain.com...]
Redirect 301 /old_2.html [domain.com...]
Redirect 301 /old_3.html [domain.com...]
Redirect 301 /old_4.html [domain.com...]

...and so on. I also do this with other file types I have replaced and renamed. This list is growing - LOL

Is there a condensed way of doing this to on avoid code bloat? For example, listing the old files that point to the same new one, all in the same redirect? Thanks.

RonPK

11:42 am on May 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



RedirectMatch is your friend. [httpd.apache.org ]

If all your old files have 'old_' in their names - which seems quite unlikely :) - try this:
RedirectMatch permanent ^/old_(.*)\.html$ newURL

A better idea is something like
RedirectMatch permanent (/old_1¦/old_2¦/old_3)\.html newURL

It looks like the forum software replaces my solid vertical bars with ¦ .

If I'm correct, you should use status descriptions, not status codes, with redirect-instructions.

I sincerely hope this helps you (I haven't tested it).

keyplyr

4:48 pm on May 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month




Thanks RonPK, but no... all my old files do not have 'old' in them. That was to exemplify my question ;) Different names, pointing to the same place.

jdMorgan

7:08 pm on May 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



keyplr,

One thing that may help is that you don't need to leave these redirects up permanently. I usually only leave mine up for 6 months or so. Offer a link to your site map on your custom 404 page to provide a last-ditch method to avoid losing visitors to old URLs.

If there is anything common about the old filenames, then RedirectMatch can help. If you use it, be sure to escape the "_" character by writing it as "\_", and replace the broken vertical pipes with solid ones as RonPK notes.

Jim

keyplyr

1:00 am on May 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Offer a link to your site map on your custom 404 page to provide a last-ditch method to avoid losing visitors to old URLs. - Jim

I actually have a site search box right on my custom 404 page, as well as a link to my site map - LOL