Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!



Photo
- - - - -

What Is The Difference Between These 301 Redirect Codes?


  • Please log in to reply
5 replies to this topic

#1 penstaar

penstaar

    HR 2

  • Active Members
  • PipPip
  • 41 posts

Posted 20 May 2009 - 12:26 PM

Hi all,

I have seen these different 301 redirect codes (switching to new domain name).
What is the difference between them?

Suggested by Randy on this forum:

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


Wikipedia:

RewriteEngine On

CODE
RewriteCond %{HTTP_HOST} ^.*oldwebsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.preferredwebsite.net/$1 [R=301,L]



My web host tech support suggested this one:

CODE
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.mysite.ca/$1 [R=301,L]



Is this suggestion from my host missing something critical?

Thanks!

#2 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 20 May 2009 - 01:59 PM

They all do similar things, though there are slight differences.

Working backwards, #3 doesn't look for any domain name or anything else as a Rewrite Condition. Meaning it is going to perform a blanket redirect of any and all traffic. Which out of necessity means it would be installed on a domain that has it's own hosting set up and things are always going to stay that way. That'll work fine as long as the domain you're forwarding traffic from is a separately hosted entity and will stay that way.

It should be okay since your host recommended it. The danger creeps in if there was something else in that hosting space (say a third domain that was parked on content in a subdirectory) that you wanted to stay the way it was. With no host name test this traffic would also get redirected.

FTR, I also see your hosting company has an Options +FollowSymlinks in there before the rewriting starts. This has to be enabled for mod_rewrite to work correctly in Apache. That they instructed you to put it in your .htaccess indicates it's not enabled by default. So if you use any other versions or any other rewrites you'll want to turn it on.

#2 does look for a domain name in its Rewrite Condition. It is looking for anything and/or nothing in the subdomain section of the domain address. That's what the .* characters are saying just before oldwebsite. It's a wildcard that will match any characters, including no characters. So it would match on oldwebsite.com, www.oldwebsite.com and also things like sub.oldwebsite.com and anything.oldwebsite.com

#1 is very similar, but is a bit more specific. It will match only on www.olddomain.com and olddomain.com. It would test false for anything else, keeping the redirect from firing. With will match on either because the www. part is set up as a conditional phrase. That's what putting it inside parens and following the closing paren with a question mark does, it makes it conditional so it can either be there or not be there and still test true.

Isn't Regex a wonderfully confusing thing?

giggle.gif

#3 penstaar

penstaar

    HR 2

  • Active Members
  • PipPip
  • 41 posts

Posted 20 May 2009 - 10:29 PM

Randy,

Thank you so much for the explanation!

It sounds like my host's suggestion #3 will work just fine for my purposes as there are no subdomains to worry about.

Thanks again.

#4 penstaar

penstaar

    HR 2

  • Active Members
  • PipPip
  • 41 posts

Posted 28 May 2009 - 01:35 AM

I ended up using the following redirect, but instead of Google indexing www.mysite.com it has indexed mysite.com.

Is there something in this code that I'm missing?

CODE
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]


Also, a page on my old site, www.oldsite.com/page.html is still indexed for the same search phrase a few below. Do I need to create a redirect for every single page? I thought the .* meant everything was redirected.

Thanks!

#5 Randy

Randy

    Convert Me!

  • Moderator
  • 17,540 posts

Posted 28 May 2009 - 09:29 AM

This redirect code is on the old domain and is pointing to the new domain?

If so, you probably just need to give it a little time. The spiders will need to try to reindex all of the pages of the old domain that they knew about, see the 301 and not it in their records.

There's nothing in the redirect that points to the non-www version. So I'd also double check any redirect instructions you have set up on the final destination domain to make sure you're consistently sending traffic to the www version of the domain.

#6 penstaar

penstaar

    HR 2

  • Active Members
  • PipPip
  • 41 posts

Posted 28 May 2009 - 10:57 AM

QUOTE(Randy @ May 28 2009, 10:29 AM) View Post
This redirect code is on the old domain and is pointing to the new domain?

If so, you probably just need to give it a little time. The spiders will need to try to reindex all of the pages of the old domain that they knew about, see the 301 and not it in their records.

There's nothing in the redirect that points to the non-www version. So I'd also double check any redirect instructions you have set up on the final destination domain to make sure you're consistently sending traffic to the www version of the domain.


Hi Randy,

Yes it's on the old pointing to the new. I guess the answer is just give it time since I haven't added set up any redirect instructions at the final destination, although I should probably do that ( send all traffic to www version ).

Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

We are now a read-only forum.
 
No new posts or registrations allowed.