How to htaccess redirect parked domains?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crunch42
    Member
    • Feb 2005
    • 43

    How to htaccess redirect parked domains?

    Anyone know what I'd write in an .htaccess file in order to redirect requests for two parked domains, abc.com and xyz.com to 123.com, which is the "real" site?

    Thanks,
    Julian
  • james
    Senior Member
    • Mar 2004
    • 183

    #2
    Code:
    Redirect / [url]http://www.123.com[/url]
    Put that in the root folder of abc.com and xyz.com.

    James

    Comment

    • crunch42
      Member
      • Feb 2005
      • 43

      #3
      I used php

      Thanks. I actually used php to do what I wanted:

      PHP Code:
      if (substr($_SERVER['HTTP_HOST'],0,7)=="www.abc") { header("Location: http://www.123.com"); } 
      I put this in an include file that was included in all pages. The parked domains had no search engine references so I figured it was safe to do it this way instead of with some kind of 301 redirect.

      - Julian
      Last edited by crunch42; 06-16-2005, 02:08 AM. Reason: To add the word "of"

      Comment

      • james
        Senior Member
        • Mar 2004
        • 183

        #4
        Julian,

        What about if someone visits your site without the www.?

        ie just http://abc.com.

        Your php code above will not redirect in this case, correct?

        James

        Comment

        • crunch42
          Member
          • Feb 2005
          • 43

          #5
          Yep

          That's true. I always forget about that eventuality. The following code works:

          PHP Code:
          if (substr($_SERVER['HTTP_HOST'],0,7)=="www.abc") { header("Location: http://www.123.com"); } 
          if (
          substr($_SERVER['HTTP_HOST'],0,3)=="abc") { header("Location: http://www.123.com"); } 

          Comment

          • james
            Senior Member
            • Mar 2004
            • 183

            #6
            I would use this instead:
            PHP Code:
            if (substr($_SERVER['HTTP_HOST'],0,7) == "www.abc" || substr($_SERVER['HTTP_HOST'],0,3)=="abc") { 
                
            header("Location: http://www.123.com"); 

            It does the same, just with slighly different logic (the || means OR)

            James

            Comment

            • felipe808
              Senior Member
              • Mar 2004
              • 111

              #7
              C panel Redirect Button

              I just noticed the Redirect page in Cpanel and installed some redirects for some old pages coming up in the "error" pages report.
              Question: can you use this redirect button with subdirectories that are old and wildcard files to eliminate doing each file?
              In other words, if i'm getting requests for "mainpage/products/thing1.html"
              could you redirect "mainpage/products/*.html" to redirect thing1 and 2...n?
              Also: why is there a "temp" and "permanent" option on the redirect page?
              Last edited by felipe808; 06-21-2005, 05:48 PM. Reason: xtra question

              Comment

              • sdjl
                Senior Member
                • Mar 2004
                • 502

                #8
                You could try doing the wildcards through the cPanel utility, although i'm not too sure how it will respond to them.
                I wrote mine by hand.

                Apache serves out temporary or permanently removed status codes to your browser. So if your browser sees a permanently removed status code, it will remember that for next time the user goes to the page. The temporary code means the old URL will mostly likely be back.

                David
                -----
                Do you fear the obsolescence of the metanarrative apparatus of legitimation?

                Comment

                • felipe808
                  Senior Member
                  • Mar 2004
                  • 111

                  #9
                  Thanks...& WILD CARDS don't work

                  they don't seem to work so it's one at a time. Thanks for the info.

                  Comment

                  • sdjl
                    Senior Member
                    • Mar 2004
                    • 502

                    #10
                    You can manually write a wildcard redirect. This may work for you.

                    Code:
                    RewriteEngine On
                    RewriteRule ^directory/this/(.*)\.html$ newpage.php?type=$1
                    David
                    -----
                    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

                    Comment

                    Working...