vBulletin Search Engine Optimization
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 ...
| |||||||
Enhancing 80 million pages. | Register | FAQ | Members List | Social Groups | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| ||||
| ||||
| Different 301 Redirect formats
Hi, Since you guys are the rewrite kings, 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! |
|
#2
| ||||
| ||||
|
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:
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. |
|
#3
| ||||
| ||||
| Quote:
Works great for forum.domain.com and domain.com/forum/ Do I need a separate rule to catch that one? |
|
#4
| ||||
| ||||
|
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. |
|
#5
| ||||
| ||||
| Quote:
HTML Code: www.domain.com/forum//home/username/public_html/forum |
|
#6
| ||||
| ||||
|
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. |
|
#7
| ||||
| ||||
|
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]
############
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. |
|
#8
| ||||
| ||||
| Quote:
__________________ 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. |
|
#9
| ||||
| ||||
| Quote:
############ 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
- - -
|
|
#10
| ||||
| ||||
|
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. |
|
#11
| ||||
| ||||
|
You the Man, Oleg. That one did the trick. Thanks!! -- John |
|
#12
| ||||
| ||||
|
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. |
|
#13
| ||||
| ||||
|
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. |
| Thread Tools | |
| |
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 |