Forum Moderators: phranque

Message Too Old, No Replies

301 redirect advice needed

A wildcard solution?

         

HarryM

7:54 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have directories which each contain pages with name formats foobar.php, foobar-gb.php, and foobar-b5.php. I want to redirect those ending -gb.php and -b5.php to pages of the same name but in different directories on a different domain.

There are about 120 pages in all, which would take a bunch of standard 301 redirects. Is there any practical limit to the number of 301's that can be used? Alternatively is there some way of doing it by using wildcards? Or by mod rewrite?

ChadSEO

8:21 pm on Aug 22, 2005 (gmt 0)

10+ Year Member



HarryM,

This would be quite easy using a mod_rewrite. Putting something like this in an .htaccess file should do the trick:

RewriteEngine On
RewriteRule ([^/]+-gb\.php)$ http://www.example.com/newdir/$1 [R=301,L]
RewriteRule ([^/]+-b5\.php)$ http://www.example.com/newdir/$1 [R=301,L]

This would redirect all files that end in either -gb.php or -b5.php to example.com/newdir/<original filename>, using a 301 redirect.

Chad

HarryM

10:18 pm on Aug 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks, Chad.

Harry