Forum Moderators: phranque

Message Too Old, No Replies

Help Redirecting Multiple URLs

         

clickfire

7:09 pm on Dec 20, 2010 (gmt 0)

10+ Year Member



I'm moving just some of the content from one domain to a new domain and need to redirect specific URLs to specific locations on the new server and then make whatever URLs are left redirect to the new domain main page.

I've set up a test on this domain (forumpoint.com) using 302's with yahoo.com and bing.com as the destinations. The below works in my firefox browser but does not report correctly with a header checker like [seoconsultants.com...] I am guessing there is a much better way to do this. Appreciate any feedback.

# Specific URLs
RedirectMatch permanent ^/test/$ http://www.yahoo.com/
RedirectMatch permanent ^/test/dirtest/ http://www.yahoo.com/
RedirectMatch permanent ^/test/dirtest/file.htm$ http://www.yahoo.com/

# Everything Else Temp
RewriteEngine on
RewriteCond %{HTTP_HOST} forumpoint\.com$ [NC]
RewriteRule ^(.*)$ http://www.bing.com/ [R=302,L]

jdMorgan

12:36 am on Dec 21, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Don't mix mod_alias and mod_rewrite, for a start. I'd suggest you change your RedirectMatch-es to RewriteRule-s.

Also, it is likely that your first three redirects could be coded as one line. Using parentheses around optional sub-patterns and following the closing parenthesis with a "?" makes that entire sub-pattern match optional. example:

RewriteRule ^test/(dirtest/(file\.html)?)?$ http://www.yahoo.com/ [R=301,L]

3 rules for the price of one...

Jim

clickfire

5:13 am on Dec 21, 2010 (gmt 0)

10+ Year Member



I was able to solve it based on your remarks. Thanks, Jim.