[.htaccess] How to redirect every (even non-exist) page on 1 site to another domain?

Discussion in 'Apache' started by Pros, Mar 28, 2010.

  1. #1
    If someone goes to my1domain.com/ or even a page that doesn't exist like my1domain.com/thisplace/does-not?q=exist (so basically anything) I want it all to redirect to the root of another domain, ie. my2domain.com (no www. on redirected domain, but will catch www. or no www. or any subdomain of my1domain.com)

    Thank you for your help.
     
    Pros, Mar 28, 2010 IP
  2. buggyB

    buggyB Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Perhaps by placing a meta refresh tag in your 404 error page.
    <meta http-equiv="refresh" content="0;url=http://my2domain.com">
    Code (markup):
    content="0 means that it will redirect the user automatically right after the browser reads the code.
     
    buggyB, Mar 28, 2010 IP
  3. Pros

    Pros Well-Known Member

    Messages:
    244
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    150
    #3
    I want to do it by 301 redirect to be search engine friendly, so preferably .htaccess.

    To give exact examples:

    http://mydomain.com/ will redirect to http://otherdomain.com/

    http://www.mydomain.com/ will redirect to http://otherdomain.com/

    http://www.mydomain.com/anypage.php will redirect to http://otherdomain.com/

    http://mydomain.com/anypage.php will redirect to http://otherdomain.com/

    http://mydomain.com/someotherthing will redirect to http://otherdomain.com/

    http://www.mydomain.com/someotherthing will redirect to http://otherdomain.com/

    http://anysubdomain.mydomain.com/ will redirect to http://otherdomain.com/

    Basically so that no matter what is typed in on mydomain.com (so http://*.mydomain.com/*) will all redirect to http://otherdomain.com/

    Does anyone know how?
     
    Pros, Jul 3, 2010 IP