vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Board Optimization - Enforce www preference in URL (https://vborg.vbsupport.ru/showthread.php?t=192364)

jcodemasters 09-30-2008 10:00 PM

Enforce www preference in URL
 
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

Milad 10-01-2008 12:57 AM

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>


SEOvB 10-01-2008 02:24 AM

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

jcodemasters 10-01-2008 02:51 AM

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

dreads 10-02-2008 01:29 AM

FRDS
Well not everyone runs apache ...

ryancooper 10-02-2008 10:58 AM

Quote:

Originally Posted by Milad (Post 1634361)
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!

Milad 10-05-2008 10:39 AM

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>


Namaless 10-13-2008 05:39 PM

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.


All times are GMT. The time now is 08:40 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01116 seconds
  • Memory Usage 1,753KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete