miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Permanent 301 redirect of ANY forum link from http://domain.any to http://www.domain.any

 
Author Paul
Lead Developer 
#1 | Posted: 25 Jul 2007 08:19 
Most of you probably know that if somebody publish a link to your original domain without 'www', it will be probably displayed anyway. However it brings headache in the terms of SEO, since it could give you a "duplicated content" penalties from search crawler like Google.

(Despite I would disagree with this opinion...)

I have studied a lot of web pages regarding this subject, but most of them offer just a redirection using Apache's .htaccess. The code offered looks like:

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


Unfortunatelly I am not Apache guru and can not extend this code so it works correctly for all cases. What kind of cases? If you simply enter http://example.com/ it will work for you redirecting to http://www.example.com/. However if you enter http://example.com/somepage.html it will not redirect to that page properly (with 'www').

Here is the simple PHP code I've programmed to put on all miniBB pages. If you are using miniBB forums, you could use it at least for your forum script, forcing redirection of any kind of forum page which is accessed without 'www', to the original domain with 'www':

$site_url='http://www.minibb.com';

if(substr($_SERVER['HTTP_HOST'], 0, 4)!='www.' and substr($_SERVER['HTTP_HOST'], 0, 9)!='localhost') {
header("HTTP/1.1 301 Moved Permanently");
header("Location:{$site_url}{$_SERVER['REQUEST_URI']}");
exit;
}

This code needs to be pasted anywhere in setup_options.php.
Feel free to apply it for any other of your web site pages as well.
Don't forget to change $site_url value of course ;-)

Check how it works:

http://minibb.com/features.html
http://minibb.com/forums/9_0.html

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Permanent 301 redirect of ANY forum link from http://domain.any to http://www.domain.any
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Try the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑