[How to] redirect a second domain

Discussion in 'Web Design and Development' started by macsig, Nov 7, 2009.

  1. macsig macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #1
    Hello guys,
    which is the best way to point a domain to a page of an other domain?

    Basically when someone goes to secondDomain.com must be redirect to domain.com/page2.

    Can I achieve so all "server side" (without create a second site with a redirect page)?


    Thanks and have a nice weekend
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    If it is a Apache web server then you can use a .htaccess file to do the redirect.

    mod_alias

    Code:
    Redirect 301 / http://www.example.com/
    If only the domain name has changed, and the site folder structure and pages are in the same place then use,
    Code:
    RewriteEngine on
    RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
     
  3. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #3
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    Yea, just use the first example I gave and provide the file name to the end.
    Code:
    Redirect 301 / http://www.example.com/page2
    For your 2nd question:
    Code:
    Redirect 301 /whatever http://www.secondDomain.com/
     
  5. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA
    #5
    thanks.
    Sorry I didn't understand what you mean the first time.

    In my second question when I put "whatever" I mean really any pages beside secondDomain.com you try to reach so can I use a regex in your second code?

    Thanks again


    Sig
     
  6. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #6
    So there's only one page, the home page? Why would they be trying to access anything else if there's only one page? If so, then you would use,
    Code:
    Redirect 301 /.+ http://www.secondDomain.com/
     
  7. macsig thread starter macrumors regular

    Joined:
    Oct 27, 2006
    Location:
    Marina del Rey, CA

Share This Page