Redirect 80,000 urls in Google serps

Discussion in 'Apache' started by bdmunee, May 18, 2006.

  1. #1
    I have a domain that has over 80,000 indexed urls/webpages in Google.

    I want to redirect each one of those urls to a different domain and/or a sub-directory/page of that different domain.

    I am currently using this in .htaccess :

    redirect 301 / http://www.newdomain.com

    It works as a redirect for the old domain for "www" and without, but only for the main/home page:

    http://www.olddomain.com redirects to http://newdomain.com
    http://olddomain.com redirects to http://newdomain.com

    My question is: How do I get all the other 79,998 indexed urls pages to redirect to the new domain?

    I have tried using the "meta refresh" code in a 404 custom error page and it isn't working. I have also tried using the 301 redirect above for each and every individual page and it doesn't seem to work either.

    Anyone have any ideas?:confused:

    btw, here is an example of one of the urls:

    olddomain.com/mod.php?mod=calendar&op=month_view&date=20060820&side_month=1125558000

    Thanks.
     
    bdmunee, May 18, 2006 IP
  2. MaxPowers

    MaxPowers Well-Known Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #2
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.olddomain.com
    RewriteRule ^(.*)$ http://www.newdomain.com/$1 [r=301,L]

    I'm actually using this to redirect my domain.NET and domain.ORG to domain.COM
     
    MaxPowers, May 18, 2006 IP
  3. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    bdmunee, May 18, 2006 IP
  4. MaxPowers

    MaxPowers Well-Known Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #4
    and you have mod_rewrite installed? I've been using this for quite some time. Test it on http://www.comptrio.net/websiteoptimization.html?and=some&other=stuff

    and it will change the domain name to comptrio.com while still going to the same inside page

    I'm only using it for the tld extension (.com, .net), but it will also work for the domain itself
     
    MaxPowers, May 18, 2006 IP
  5. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes it must be installed because it does work for redirecting olddomain.com to newdomain.com but it won't work for the messy urls I have indexed in Google.

    Here is what I am using right now:

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^www.olddomain.com
    RewriteRule ^(.*)$ http://www.newdomain.org/$1 [r=301,L]

    Could you tell me how to redirect to a sub-directory or sub-page?
    I am assuming that it would just be: RewriteRule ^(.*)$ http://www.newdomain.org/subpage.html$1 [r=301,L]
    instead of: RewriteRule ^(.*)$ http://www.newdomain.org/$1 [r=301,L]
     
    bdmunee, May 18, 2006 IP
  6. MaxPowers

    MaxPowers Well-Known Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #6
    ^(.*)$ takes everything from after the domain name up to the last character of your URL and returns it in $1

    Try dropping the
    RewriteCond %{HTTP_HOST} ^www.olddomain.com
    because you're redirecting ALL traffic from old to new, there may be no need to specify that this is conditional.
     
    MaxPowers, May 18, 2006 IP
  7. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Still doesn't work:(

    I also checked that the ".txt" is NOT on the end of the .htaccess and the permissions are "644"

    btw, here are some example urls I'm trying to redirect:

    olddomaindotcom/mod.php?mod=calendar&op=month_view&date=20060524&side_month=1120201200

    olddomaindotcom/mod.php?mod=calendar&op=view_day&date=20050415&side_month=1117609200

    olddomaindotcom/mod.php?mod=calendar&op=view_day&date=20050813&side_month=1107162000
     
    bdmunee, May 18, 2006 IP
  8. MaxPowers

    MaxPowers Well-Known Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #8
    please post or pm me with your domain so I can take a better look, perhaps.
     
    MaxPowers, May 18, 2006 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #9
    Are all 79,998 old URLs like...

    olddomaindotcom/mod.php?mod=calendar&op=month_view&date=20060524&side_month=1120201200
    olddomaindotcom/mod.php?mod=calendar&op=view_day&date=20050415&side_month=1117609200

    What are the new URLs like?
     
    Nintendo, May 18, 2006 IP
  10. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Yes, that is what all the urls are like. I want to redirect them to:

    newdomain.com/blahblah.html

    newdomain.com/morenonsense.html

    Thanks.
     
    bdmunee, May 18, 2006 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #11
    What would the URLs actually look like, as in,

    calendar/month/20060524/1120201200.html for example.
     
    Nintendo, May 18, 2006 IP
  12. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Just plain, old static urls:

    directory/subpage.html
     
    bdmunee, May 18, 2006 IP
  13. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #13
    month_view

    olddomaindotcom/mod.php?mod=calendar&op=month_view&date=XXXXX&side_month=YYYYY
    to
    month/XXXXX/YYYYY.html

    view_day

    olddomaindotcom/mod.php?mod=calendar&op=view_day&date=XXXXX&side_month=YYYYY
    to
    day/XXXXX/YYYYY.html


    domain.com/.htaccess on old domain.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^mod\.php?mod=calendar&op=month_view&date=([^.]+)&side_month=([^.]+)$ http://www.domain.com/month/$1/$2.html [R=301,L]
    RewriteRule ^mod\.php?mod=calendar&op=view_day&date=([^.]+)&side_month=([^.]+)$ http://www.domain.com/day/$1/$2.html [R=301,L]

    domain.com/.htaccess on new domain.

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^month/([^.]+)/([^.]+)\.html$ mod.php?mod=calendar&op=month_view&date=$1&side_month=$2 [L]
    RewriteRule ^day/([^.]+)/([^.]+)\.html$ mod.php?mod=calendar&op=view_day&date=$1&side_month=$2 [L]
     
    Nintendo, May 18, 2006 IP
  14. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #14

    Thanks a lot - much appreciated.
    How about if I just wanted to redirect all the urls to the same top level domain home page like: www.newdomain.com

    What would that look like?
     
    bdmunee, May 18, 2006 IP
  15. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #15
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^mod\.php?mod=calendar&op=month_view&date=([^.]+)&side_month=([^.]+)$ http://www.domain.com/ [R=301,L]
    RewriteRule ^mod\.php?mod=calendar&op=view_day&date=([^.]+)&side_month=([^.]+)$ http://www.domain.com/ [R=301,L]

    with no .htaccess needed on the new domain.
     
    Nintendo, May 19, 2006 IP
  16. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #16

    Still not working with OR without the "Options +Indexes
    Options +FollowSymlinks"

    It's really strange how when I upload the .htaccess file via FTP, it renames the file ".htaccess" to ".htaccess.txt" and then when I refresh the view window in the FTP client - the file disappears from view (but it is still residing in that directory). Of course, I am deleting the ".txt" part.

    Is it likely that my web host provider has the server configured to not accept certain types of calls in .htaccess?

    The code from my earlier post above seems to work, but only for the top level domain: www.mydomain.com and mydomain.com

    Very frustrating :confused:
     
    bdmunee, May 19, 2006 IP
  17. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #17
    Try (.*) instead of ([^.]+).
     
    Nintendo, May 19, 2006 IP
  18. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #18
    still not working.
     
    bdmunee, May 19, 2006 IP
  19. MaxPowers

    MaxPowers Well-Known Member

    Messages:
    264
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    120
    #19
    try to slash before the ? in Nintendos code...

    This should get the regex to handle the URL correctly and may be why the main page worked, but not the dynamic URLs
     
    MaxPowers, May 19, 2006 IP
  20. bdmunee

    bdmunee Peon

    Messages:
    420
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #20
    I finally got it to redirect all of those 80k dynamic url's.
    :D

    This is the code that did it:

    Options +FollowSymlinks
    RewriteEngine On
    RewriteRule ^(.+)$ http://newdomain.com/
    RedirectMatch permanent ^/$ http://newdomain.com/
     
    bdmunee, May 21, 2006 IP