Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.6 > vBulletin 3.6 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Enforce www preference in URL Details »»
Enforce www preference in URL
Version: 1.00, by jcodemasters jcodemasters is offline
Developer Last Online: Oct 2015 Show Printable Version Email this Page

Category: Board Optimization - Version: 3.6.4 Rating:
Released: 09-30-2008 Last Update: Never Installs: 3
Code Changes Is in Beta Stage  
No support by the author.

Hello,
After an year I finally got some time to look at my poor board which is losing page rank in every google update. I am currently optimizing my forum, while doing this i found there was duplicate content issue in my forum. See this example

http://myvbforum.com Page rank 0
http://www.myvbforum.com Page rank 2
http://www.myvbforum.com/index.php Page rank 1

You can see from above urls all have same contents but different page rank also Google consider them different urls and those cause the duplicate contents problem.

In order to avoid duplicate contents issue you should add following code to your config.php on second line below this ini_set("max_execution_time", "240");

PHP Code:
$web_home 'http://www.REPLACE_WITH_YOUR_FORUM_URL.com';

if ( 
$_SERVER['REQUEST_URI'] == str_replace('http://' $_SERVER['HTTP_HOST'], ''$web_home) . '/index.php' ) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: ' $web_home '/');
exit();
}
if ( 
strpos($_SERVER['HTTP_HOST'], 'www.') === 0  && strpos($web_home'http://www.') === false ) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: [url]http://'[/url] . substr($_SERVER['HTTP_HOST'], 4) . $_SERVER['REQUEST_URI']);
exit();
} elseif ( 
strpos($_SERVER['HTTP_HOST'], 'www.') !== && strpos($web_home'http://www.') === ) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: [url]http://www[/url].' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();

I have tested it in VB 3.6.4 and it works fine. I am not VB expert this could be a plugin, if you can make it then please upload here.

Have Fun

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 10-01-2008, 12:57 AM
Milad's Avatar
Milad Milad is offline
 
Join Date: Apr 2005
Location: Syro
Posts: 663
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In .htaccess

Code:
<IfModule mod_rewrite.c>
	RewriteEngine On
	# Rewrite for including www
	RewriteCond %{HTTP_HOST} ^yourdomain.com
	RewriteRule (.*)$ http://www.yourdomain.com/$1 [L,R=301]
</IfModule>
Reply With Quote
  #3  
Old 10-01-2008, 02:24 AM
SEOvB's Avatar
SEOvB SEOvB is offline
 
Join Date: May 2007
Location: Indianapolis
Posts: 2,451
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yea, not sure why you'd do it the way you did when a simple .htaccess would do

Also, google no longer treats those pages as duplicate content as it's pretty smart these days. You should find other reasons why you're losing pagerank
Reply With Quote
  #4  
Old 10-01-2008, 02:51 AM
jcodemasters jcodemasters is offline
 
Join Date: Aug 2006
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Its just method I described it here. Its up to vb users whether they use it or not. I am just sharing it.

P.s: index.php option is missing in htaccess and I think easy way is to use htaccess
Reply With Quote
  #5  
Old 10-02-2008, 01:29 AM
dreads dreads is offline
 
Join Date: Feb 2007
Posts: 141
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

FRDS
Well not everyone runs apache ...
Reply With Quote
  #6  
Old 10-02-2008, 10:58 AM
ryancooper ryancooper is offline
 
Join Date: Jul 2002
Posts: 433
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Milad View Post
In .htaccess

Code:
<IfModule mod_rewrite.c>
	RewriteEngine On
	# Rewrite for including www
	RewriteCond %{HTTP_HOST} ^yourdomain.com
	RewriteRule (.*)$ http://www.yourdomain.com/$1 [L,R=301]
</IfModule>
Cool tHanks!
Reply With Quote
  #7  
Old 10-05-2008, 10:39 AM
Milad's Avatar
Milad Milad is offline
 
Join Date: Apr 2005
Location: Syro
Posts: 663
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this

In .htaccess

Code:
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteRule ^index\.php http://www.yourdomain.com/ [L,R=301]
	# Rewrite for including www
	RewriteCond %{HTTP_HOST} ^yourdomain.com
	RewriteRule (.*)$ http://www.yourdomain.com/$1 [L,R=301]
</IfModule>
Reply With Quote
  #8  
Old 10-13-2008, 05:39 PM
Namaless's Avatar
Namaless Namaless is offline
 
Join Date: Sep 2006
Location: Italy
Posts: 222
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have choose to add into Plugins Manager and works correctly with BBURL vBulletin variable:

init_startup
PHP Code:
$web_home $vbulletin->options['bburl'];

if ( 
$_SERVER['REQUEST_URI'] == str_replace('http://' $_SERVER['HTTP_HOST'], ''$web_home) . '/index.php' )
{
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: ' $web_home '/');
    exit();
}

if ( 
strpos($_SERVER['HTTP_HOST'], 'www.') === 0  && strpos($web_home'http://www.') === false )
{
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: http://' substr($_SERVER['HTTP_HOST'], 4) . $_SERVER['REQUEST_URI']);
    exit();
}
else if ( 
strpos($_SERVER['HTTP_HOST'], 'www.') !== && strpos($web_home'http://www.') === )
{
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: http://www.' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    exit();

No need any modifications or settings.

Regards.
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 04:08 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04044 seconds
  • Memory Usage 2,291KB
  • Queries Executed 21 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete