vBulletin SEO Forums

SEO

vBulletin Search Engine Optimization

Buy vBSEO Now! HACKER SAFE certified sites prevent over 99.9% of hacker crime.
ne nw
vBSEO Total Support Team Launches DeskPro New vBSEO Discount Level for Network Builders vBSEO 3.2.0 GOLD Has Landed Success with vBSEO = 600ore Web Visitors + $1400 in a Day! Crawlability Inc. Files for SEO Technology Patent
se sw

Different 301 Redirect formats

This is a discussion on Different 301 Redirect formats within the General Discussion forums, part of the vBulletin SEO Discussion category; Hi, Since you guys are the rewrite kings, Can anyone explain the differences between these two different 301 redirect statements ...

Go Back   vBulletin SEO Forums > vBulletin SEO Discussion > General Discussion

Enhancing 80 million pages.

Register FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read
  #1  
Old 11-18-2006, 05:43 PM
oddmusic's Avatar
Junior Member
 
Real Name: John
Join Date: Nov 2006
Posts: 10
Different 301 Redirect formats

Hi,

Since you guys are the rewrite kings, Can anyone explain the differences between these two different 301 redirect statements below please. This is only to redirect "domain.com" to "www . domain.com" to consolidate links. They both seem to do the same thing, but the vBSEO folks recommended the first one, and I was using the second one before setting up a forum in a sub-directory of my website, so I'd like to know the differences and if one way is better, etc.

The redirect is in my root dir .htaccess file, and not my in my /forum subdirectory. They both also work fine when accessing the forum with either "forum.domain.com" or "www . domain.com/forum" or "domain.com/forum" so I have not modified my .htaccess file in the /forum directory to do any custom re-writing as far as "www / non-www" stuff goes, so I'll leave that file alone for now.

Here's the two different versions:

RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteCond %{http_host} ^domain.com [nc]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,nc]

Which one is preferred? Both the same?

On another different note, when I type: forum.domain.com or domain.com/forum/ (with trailing slash) both of those urls stay the same in the browser heading, and once a click is made on anything, it changes to "www . domain.com/forum" because the url's are already re-written. If I go to domain.com/forum (without the slash) it gets re-written right away to "www . domain.com/forum". I don't think there is any issue with that, since the first two get changed to the preferred format "www.domain.com/forum" once any action is taken by the user, unless you think I should have rewrites for that?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #2  
Old 11-19-2006, 07:51 AM
Oleg Ignatiuk's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Oleg Ignatiuk
Join Date: Jun 2005
Location: Belarus
Posts: 21,597
Hello John,

[NC] attribute means case-insensitive comparison, but in this case it is not required since hostname is always provided in lower case.
[L] attribute mean last rule - so redirect is applied immediately, no further rewrite rules are processed in .htaccess
Quote:
On another different note, when I type: forum.domain.com or domain.com/forum/ (with trailing slash) both of those urls stay
You should insert similar rewrite rule in forum/.htaccess file right after "RewriteEngine on" line:

Code:
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/forum/$1 [R=301,L]
__________________
Oleg Ignatiuk / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #3  
Old 11-19-2006, 06:05 PM
oddmusic's Avatar
Junior Member
 
Real Name: John
Join Date: Nov 2006
Posts: 10
Quote:
Originally Posted by Oleg Ignatiuk View Post
You should insert similar rewrite rule in forum/.htaccess file right after "RewriteEngine on" line:

Code:
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/forum/$1 [R=301,L]
Thanks, Oleg. The one problem it's having with those rules in the forum .htaccess file is that if I type: domain.com/forum (without a trailing slash) I get a 404 error.

Works great for forum.domain.com and domain.com/forum/

Do I need a separate rule to catch that one?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #4  
Old 11-19-2006, 07:35 PM
Oleg Ignatiuk's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Oleg Ignatiuk
Join Date: Jun 2005
Location: Belarus
Posts: 21,597
Try to add another rewrite rule to the root .htaccess for that:
Code:
RewriteRule ^forum$ http://www.domain.com/forum/ [R=301,L]
__________________
Oleg Ignatiuk / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #5  
Old 11-19-2006, 08:02 PM
oddmusic's Avatar
Junior Member
 
Real Name: John
Join Date: Nov 2006
Posts: 10
Quote:
Originally Posted by Oleg Ignatiuk View Post
Try to add another rewrite rule to the root .htaccess for that:
Code:
RewriteRule ^forum$ http://www.domain.com/forum/ [R=301,L]
Getting closer, but that rule (in either root or /forum .htaccess) causes the rewrite to do this:

HTML Code:
www.domain.com/forum//home/username/public_html/forum
giving a 404
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #6  
Old 11-19-2006, 08:11 PM
Oleg Ignatiuk's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Oleg Ignatiuk
Join Date: Jun 2005
Location: Belarus
Posts: 21,597
Try changing it to:
Code:
RewriteRule ^forum$ http://www.domain.com/forum/? [R=301,L]
__________________
Oleg Ignatiuk / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #7  
Old 11-19-2006, 08:29 PM
oddmusic's Avatar
Junior Member
 
Real Name: John
Join Date: Nov 2006
Posts: 10
Still was getting the 404. I was seeing some strangeness messing around with a couple things, like logging in, then removing the "www" from the url, and then it looked like I was not logged in. So, starting from scratch, and getting rid of a couple things, taking the sub-domain out of the picture as well for now (forum . domain.com) to have a clean slate, so nothing extra in the /forum .htaccess at the moment other than the defaults.

Here's what's there now, and what's working and not working:

In the website root .htaccess file for non-www redirection to www for main website (not forum based)
Code:
############
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
############
This causes redirects for non-www url's to get changed to www
Works fine for the website, and also does a perfect redirect for domain.com/forum (with no trailing slash) which gets redirected to: www .domain.com/forum/

All good so far, but if I go to: domain.com/forum/ (with trailing slash) it does not redirect at all.

All of the URLs on the page point to www .domain.com so it does not really seem like that big of a deal, but I noticed that if you log in (with the page not redirected) it looks like you are not logged in at all even though you are. If you click on a link or thread, then you will see you are logged in, because the links have the proper url's in them, but if you just reload the page with clicking on anything, it doesn't look like you are logged in (no welcome message, guest browsing message is on, etc)

And also, if I'm logged in fine as Admin or User, and I take away the "www" from the url and reload the page, it also looks like I'm not logged in, and browsing the forum as a guest. But, if I leave it with the "www" and still looking like I'm not logged in, and just take away the trailing slash, and then reload the page, it redirects fine again and shows I'm still logged in.

So looks like the one thing I need to get going is proper redirection of domain.com/forum/ (with slash) to --> www .domain.com/forum/

and it's that trailing slash that's killing me

Anyway, sorry for all the junk here, just trying to get things going, and thanks for the help so far.

Last edited by oddmusic; 11-20-2006 at 02:49 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #8  
Old 11-20-2006, 08:04 AM
Oleg Ignatiuk's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Oleg Ignatiuk
Join Date: Jun 2005
Location: Belarus
Posts: 21,597
Quote:
All good so far, but if I go to: domain.com/forum/ (with trailing slash) it does not redirect at all.
If you have .htaccess in the forum folder (I'm assuming you have vBSEO's .htaccess in it), you need corresponding rewrite rules in it as well (as I described in the post above).
__________________
Oleg Ignatiuk / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #9  
Old 11-20-2006, 03:48 PM
oddmusic's Avatar
Junior Member
 
Real Name: John
Join Date: Nov 2006
Posts: 10
Quote:
Originally Posted by Oleg Ignatiuk View Post
If you have .htaccess in the forum folder (I'm assuming you have vBSEO's .htaccess in it), you need corresponding rewrite rules in it as well (as I described in the post above).
Here's what I get with these rules in the root .htaccess:
############
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
############
and with these rules (below) in the /forum .htaccess file. I tried with the one rule, then the other, then both, then both reversed, and also with the rule you mentioned also putting in the root .htaccess folder, and the results I get with different combinations are:
Code:
- - -
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule ^forum$ http://www.domain.com/forum/ [R=301,L]

domain.com/forum   - good redirect
domain.com/forum/  - no redirect
www.domain.com/forum  works fine with or without trailing slash
- - -

- - - 
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/forum/$1 [R=301,L]

domain.com/forum    - 404   http://www.domain.com/forum//home/username/public_html/forum
domain.com/forum/  - good redirect
www.domain.com/forum   works fine with or without trailing slash
- - - 

- - -
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule (.*) http://www.domain.com/forum/$1 [R=301,L]
RewriteRule ^forum$ http://www.domain.com/forum/ [R=301,L]

domain.com/forum     - 404  http://www.domain.com/forum//home/username/public_html/forum
domain.com/forum/  - good redirect
www.domain.com/forum   works fine with or without trailing slash
- - - 

- - -
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteRule ^forum$ http://www.domain.com/forum/ [R=301,L]
RewriteRule (.*) http://www.domain.com/forum/$1 [R=301,L]

domain.com/forum     - 404  http://www.domain.com/forum//home/username/public_html/forum
domain.com/forum/   - puts http://www.domain.com/forum/ in browser window, tries to do redirect
but doesn't come up.  Firefox browser says: Firefox has detected that the server is redirecting
the request for this address in a way that will never complete.  IE browser just spins

www.domain.com/forum  - 404 http://www.domain.com/forum//home/username/public_html/forum

www.domain.com/forum/  - tries to do redirect but doesn't come up.  
Firefox browser says: Firefox has detected that the server is redirecting the request
for this address in a way that will never complete.  IE browser just spins
- - -
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #10  
Old 11-20-2006, 05:22 PM
Oleg Ignatiuk's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Oleg Ignatiuk
Join Date: Jun 2005
Location: Belarus
Posts: 21,597
Ok, try to change rewrite rules in forum/.htaccess to:
Code:
RewriteCond %{HTTP_HOST} !^www\.domain\.com
RewriteCond %{THE_REQUEST} forum/
RewriteRule (.*) http://www.domain.com/forum/$1 [R=301,L]
__________________
Oleg Ignatiuk / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #11  
Old 11-20-2006, 05:37 PM
oddmusic's Avatar
Junior Member
 
Real Name: John
Join Date: Nov 2006
Posts: 10
You the Man, Oleg. That one did the trick. Thanks!!

-- John
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #12  
Old 11-20-2006, 05:57 PM
Oleg Ignatiuk's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Oleg Ignatiuk
Join Date: Jun 2005
Location: Belarus
Posts: 21,597
Great!
__________________
Oleg Ignatiuk / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
  #13  
Old 03-16-2008, 12:47 PM
Joe Ward's Avatar
vBSEO Staff
vBSEO Total Customer SupportvBSEO Documenter
 
Real Name: Joseph Ward
Join Date: Jun 2005
Location: Puerto Rico
Posts: 19,745
Blog Entries: 7
Related resource:
[How to] Setup www.yourdomain.com or yourdomain.com (www vs. non-www) - With .htaccess 301 redirects
__________________
Joe Ward / Crawlability Inc.
Support Team Launches New DeskPro Powered Tool Enhanced Support at Your Service

vBSEO 3.2.0 Launched - Maximum Overdrive for Your Web Traffic! Over 100 Instant SEO Optimizations

6X Traffic - $1400 in One Day with vBSEO! Imagine What the vBSEO Patent Pending Technology Can Do For You.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on Facebook!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
301 fügt ?vbseourl= mit an Junior Deutsch 8 11-20-2006 02:07 PM
301 redirect 404 pages? Steve Off-Topic & Chit Chat 5 10-22-2006 07:47 AM
301 Redirect Original Content (posts) thecat Troubleshooting 2 10-04-2006 11:00 AM
General 301 Redirect / Regular Expression Request GateKeeper URL Rewrite Settings 0 06-17-2006 12:27 PM
Stuck setting up a 301 redirect Pixalo URL Rewrite Settings 3 06-06-2006 06:36 PM


All times are GMT -4. The time now is 01:46 AM.


Powered by vBulletin Version 3.8.0 Beta 4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.5 ©2008, Crawlability, Inc.