Basic 301 Redirect Help?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DomainDog
    Senior Member
    • Mar 2004
    • 158

    Basic 301 Redirect Help?

    I need to permanantly redirect one URL to another. Does anyone know the implications (good or bad) and the exact syntax for doing this inside the .htaccess file?

    I need something like this- redirect 301 OldURL.com NewURL2.com

    And should this .htacess file be in the public html directory or at the / (home) level?
    ** Custom Graphics **
    ** FLASH Animations **
    ** Specialty Domains **
    ** Website Design **
  • sdjl
    Senior Member
    • Mar 2004
    • 502

    #2
    This is taken from the apache manual:



    "Redirect permanent /foo/ http://www.example.com/bar/"

    You might also want to look at this as the above won't output the 301 status message that you want:



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

    Comment

    • Jonathan
      Senior Member
      • Mar 2004
      • 1229

      #3
      PHP Code:
      <?php
      header
      ("HTTP/1.1 301 Moved Permanently");
      header("Location: http://www.newdomain.com/page.html");
      exit();
      ?>
      SEO friendly
      "How can someone be so distracted yet so focused?"
      - C

      Comment

      • Buddha
        Senior Member
        • Mar 2004
        • 825

        #4
        Admin friendly too. You can eventual drop the 301 when the search engines get the new link indexed.
        "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

        Comment

        • DomainDog
          Senior Member
          • Mar 2004
          • 158

          #5
          You guys rock!

          I wonder if any of those methods have an effect on the Google Pagerank?

          I've heard that redirects can cause disasterous drops, which can in turn mean sinking to the netherworld of Google search engine returns.
          ** Custom Graphics **
          ** FLASH Animations **
          ** Specialty Domains **
          ** Website Design **

          Comment

          • Buddha
            Senior Member
            • Mar 2004
            • 825

            #6
            Originally posted by DomainDog
            You guys rock!

            I wonder if any of those methods have an effect on the Google Pagerank?

            I've heard that redirects can cause disasterous drops, which can in turn mean sinking to the netherworld of Google search engine returns.
            As long as your not doing anything hinky, there should be no problem with either of those methods. 302's and meta redirects will not make search engines happy.

            Basically search engines don't want you screwing up there SERPs. So you move something tell the SE by putting up a 301 redirect. Don't just delete the page that one of the worsest things you can do.
            "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

            Comment

            • brett
              Member
              • Mar 2004
              • 45

              #7
              Does anyone know if a rewrite rule is bad for the search engines?

              I have a site like: the-domain.com being rewritten with .htaccess to thedomain.com. If the one with the dash had all the traffic, did I just screw up my listing in the big engines using the code below?

              BTW - This is how I did it and it's quite cool (if this should be different, please enlighten me):

              RewriteEngine On
              Options +FollowSymlinks
              RewriteCond %{HTTP_HOST} ^the-domain\.com [OR]
              RewriteCond %{HTTP_HOST} www\.the-domain\.com
              RewriteRule ^(.*)$ http://www.thedomain.com/$1 [R=permanent,L]

              Comment

              • Buddha
                Senior Member
                • Mar 2004
                • 825

                #8
                Originally posted by brett
                Does anyone know if a rewrite rule is bad for the search engines?

                I have a site like: the-domain.com being rewritten with .htaccess to thedomain.com. If the one with the dash had all the traffic, did I just screw up my listing in the big engines using the code below?

                BTW - This is how I did it and it's quite cool (if this should be different, please enlighten me):

                RewriteEngine On
                Options +FollowSymlinks
                RewriteCond %{HTTP_HOST} ^the-domain\.com [OR]
                RewriteCond %{HTTP_HOST} www\.the-domain\.com
                RewriteRule ^(.*)$ http://www.thedomain.com/$1 [R=permanent,L]
                IMO it looks ok, it should avoid any duplicate content penalty. I use a similar one but it redirects all parked domains to the main domain.

                Code:
                RewriteEngine on
                RewriteCond %{HTTP_HOST} !^$
                RewriteCond %{HTTP_HOST} !^www\.maindomain\.com [NC]
                RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301,L]
                "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                Comment

                • brett
                  Member
                  • Mar 2004
                  • 45

                  #9
                  Thank you!!!
                  So I could use your example instead of adding additional tags for [OR] this [OR] this [OR], etc? I had mine all parked as well. If yours covers any domain that points there, I like your example much better!
                  I just need a yes or no, then I'll begin my experimenting.

                  Thanks again!

                  Comment

                  • Buddha
                    Senior Member
                    • Mar 2004
                    • 825

                    #10
                    Originally posted by brett
                    Thank you!!!
                    So I could use your example instead of adding additional tags for [OR] this [OR] this [OR], etc? I had mine all parked as well. If yours covers any domain that points there, I like your example much better!
                    I just need a yes or no, then I'll begin my experimenting.

                    Thanks again!
                    Yes it would avoid those OR's.
                    "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                    Comment

                    • DomainDog
                      Senior Member
                      • Mar 2004
                      • 158

                      #11
                      What about redirecting
                      http://Domain.com to http://www.Domain.com?
                      ** Custom Graphics **
                      ** FLASH Animations **
                      ** Specialty Domains **
                      ** Website Design **

                      Comment

                      • Buddha
                        Senior Member
                        • Mar 2004
                        • 825

                        #12
                        Originally posted by DomainDog
                        What about redirecting
                        http://Domain.com to http://www.Domain.com?
                        If that was directed at my rewrite then yes it does do that.
                        "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                        Comment

                        • DomainDog
                          Senior Member
                          • Mar 2004
                          • 158

                          #13
                          Yet, there something in the zone file that seem to do some kind of redirect. Or maybe it's aliasing.....

                          I know my FTP program show a www alias, and there is a folder titled www that seems to duplicate everything in the home directory. But I don't WANT to have two seperate URLs! I want the non-www to redirect permanant to the www version.

                          Sorry if I seem confused. This stuff gets pretty arcane!

                          DD
                          ** Custom Graphics **
                          ** FLASH Animations **
                          ** Specialty Domains **
                          ** Website Design **

                          Comment

                          • Buddha
                            Senior Member
                            • Mar 2004
                            • 825

                            #14
                            Originally posted by DomainDog
                            Yet, there something in the zone file that seem to do some kind of redirect. Or maybe it's aliasing.....

                            I know my FTP program show a www alias, and there is a folder titled www that seems to duplicate everything in the home directory. But I don't WANT to have two seperate URLs! I want the non-www to redirect permanant to the www version.

                            Sorry if I seem confused. This stuff gets pretty arcane!

                            DD
                            The www alias is a symlink and I think it's there for convenience only. You may also be thinking of the CNAME for www in your DNS.

                            Maybe something like this will work for you?

                            Code:
                            RewriteEngine on
                            RewriteCond %{HTTP_HOST} ^maindomain\.com [NC]
                            RewriteRule ^(.*)$ http://www.maindomain.com/$1 [R=301,L]
                            Yes your very confusing! Now I know how others feel when they read my own post.
                            "Whatcha mean I shouldn't be rude to my clients?! If you want polite then there will be a substantial fee increase." - Buddha

                            Comment

                            • -Oz-
                              Senior Member
                              • Mar 2004
                              • 545

                              #15
                              Originally posted by DomainDog
                              What about redirecting
                              http://Domain.com to http://www.Domain.com?
                              Try the FAQ: http://forums.dathorn.com/showthread.php?t=281
                              Dan Blomberg

                              Comment

                              Working...