MyBB Community Forums

Full Version: Help with Redirecting forum in subdirectory to display WWW. in url
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello,

We installed the forum on a subdirectory of the site and the default for the forum is a "naked URL" i.e. "example.com/forum" not "www.example.com/forum".

This is our forum (shortened URL with Google)

The forum is very new and we were supposed to have a look at it earlier, but now threads have been created and Google has indexed us (better than I experienced with vBulletin). We are also using the myBB Google SEO plugin.

We want to redirect so that the forum goes from "example.com/forum/" to "www.example.com/forum/". Our main worry is that we now do this redirecting and create a big issue with the Google SEO plugin and or structure of the threads/URL. Because we have threads already created by members, we're fearing we break them both SEO-wise and in terms of internal structure.

1) We believe we know what code to use but I'd appreciate if you could double check with me that this is the correct code to use to have the forum permanently displaying the www.

# Redirect non-www visitors to www.
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^yourdomain.com/forum/ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/forum/$1 [L,R=301]

Are the above 3 lines (of code) all we need to have "www." in the url permanently? If not, can you please correct it. Please note that our forum is in a subdirectory (www.example.com/forum/) and that the domain root (www.example) already is redirected to display "www." (we didn't want to use the forum as a main portal).



2) Since we are using Google SEO plugin, where shall we place the code from Point 1? Shall we have a new .htaccess file or insert the code in the .htaccess file that contains the rewriting instructions for Google SEO plugin? If it is the latter option, where in the file do we place the 3 lines of code? Right at the top and before the code for the Google SEO plugin or after?

Also, should we place this .htaccess file ine root of the forum or in the root of the domain?



3) Am I right in assuming the aforementioned 3 lines of code will make the change in all existing threads and pages? Or do we have to add more coding so that any current threads/pages permanently display "www."?



For what is worth, the forum currently displays threads as "example.com/thread-XY" by default and if you type in "www." at the beginning of the URL of a thread, it redirects back to the URL without the "www.". However, paradoxically, the index page (i.e. root of the forum) does take accept both "www.example.com/forum/" and "example.com/forum/".

Really appreciate any help please.
In the CP Admin, fix the setting for your forum url (General Settings => Board URL). This should be http://www.example.com/forum/ - thus including the www for all links generated by MyBB.

Place your .htaccess snippit in your forum folder so it only gets processed for forum requests.
(2013-05-20, 05:41 PM)laie_techie Wrote: [ -> ]In the CP Admin, fix the setting for your forum url (General Settings => Board URL). This should be http://www.example.com/forum/ - thus including the www for all links generated by MyBB.

Place your .htaccess snippit in your forum folder so it only gets processed for forum requests.

Thank you!

If I change to http://www.example.com/forum/ in the board settings, shall I use the 3 lines of code that I posted for the .htaccess file? And should I place the code in the .htaccess file where all the rewriting instructions are for the Google SEO plugin?

Apologies, I just realized the address for the forum was misspelled in the original post. I have corrected it in the OP, but here it is again http://goo.gl/WCp7m
You probably don't need Options +FollowSymLinks as that has nothing to do with redirecting. I would keep the other lines, though. Put them in the same .htaccess file as is used for Google SEO, but put them before any other rules.
(2013-05-22, 06:46 PM)laie_techie Wrote: [ -> ]You probably don't need Options +FollowSymLinks as that has nothing to do with redirecting. I would keep the other lines, though. Put them in the same .htaccess file as is used for Google SEO, but put them before any other rules.

Thanks!! We changed the board settings and now threads include the "www.". The only issue is that we still have the index page showing up without the "www.".

Should we just add then at the beginning of the .htaccess

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


We have seen some people mention

Options +FollowSymLinks

at the beginning of the code while others mention

RewriteEngine On
RewriteBase /


Which one should we use or should we just use the

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


?

And while we are at it, how could we make it so that the index.php page (www.example.com/forum/index.php) redirects to www.example.com/forum/ . Again, I've been researching the code but I get several different answers and screwing up the .htaccess is my main concern.
Options +FollowSymLinks means that your web server should follow symbolic links when trying to resolve a URL to a path on the file system. I use them on my system to maintain different versions of software while only having a single URL. In my case, I have a different folder outside the DOC_ROOT for each version of MyBB and have a single symbolic link inside DOC_ROOT called forums which points to the correct version. Symbolic links neither help nor hinder redirecting from one host to another.

Do you want to redirect EVERYTHING on example.com to www.example.com, or just what's under /forum/?

RewriteEngine On means that you may potentially rewrite URLs. RewriteBase indicates the base url to match -- anything outside this base will be left alone.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com$1 [L,R=301]
(2013-05-23, 06:10 PM)laie_techie Wrote: [ -> ]Options +FollowSymLinks means that your web server should follow symbolic links when trying to resolve a URL to a path on the file system. I use them on my system to maintain different versions of software while only having a single URL. In my case, I have a different folder outside the DOC_ROOT for each version of MyBB and have a single symbolic link inside DOC_ROOT called forums which points to the correct version. Symbolic links neither help nor hinder redirecting from one host to another.

Do you want to redirect EVERYTHING on example.com to www.example.com, or just what's under /forum/?

RewriteEngine On means that you may potentially rewrite URLs. RewriteBase indicates the base url to match -- anything outside this base will be left alone.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com$1 [L,R=301]

Thank you for the help Wink

The domain root is already set as www.example.com as we have installed Wordpress on the root and it's very easy to have it showing up as www.example.com and not example.com . We then installed the forum on a subfolder (i.e. www.example.com/forum/) and right now, the forum-subfolder root is the only part of the forum that shows up as both

example.com/forum/
www.example.com/forum/

Both the domain root and the threads now show up with the www. by default, so the only pages left in the site that show up as www. and without the www. are the index page and the rest of pages. All these pages is what we now want to be exclusively with the www. in the URL; mostly because of SEO and duplicate issues.

Perhaps something could be written in the .htaccess on the root domain that says everything on the site should be www. ?? Feel free to have a look at the sites again so you see the configuration

Where the forum is is terrible because the index page is a duplicate and it has both www. and non-www. !! I'd appreciate if you can also tell me how to redirect

www.example.com/forum/index.php

to

www.example.com/forum/

Please not that the word "forum" is already in the domain name by default, and in our case we call the forum folder "talk", so it is actually www.exampleforum.com/talk/

Apologies for the Google shortener but it's a precaution I'd rather take.

The Wordpress is actually installed in another folder but redirected to appear in the domain root.

We literally want absolutely everything in the site to display www. and the pages of theforum are the only ones left to redirect. If a simple code in the root .htaccess will do this then I'm happy to do so and can post what the root .htaccess has since it already has a redirection rule.

Thanks so much. I'm very happy with myBB as a forum software compared to vBulletin.
The code I posted last should go in a .htaccess file in your DOC_ROOT to rewrite EVERYTHING to use www. DOC_ROOT is the folder on your server which is served as http://www.example.com/ . Domain only contains the name of the server; it does not include any folders.

As to http://www.example.com/forum/index.php redirecting to http://www.example.com/forum/ for SEO (Search Engine Optimization) purposes, you may want to include something like [i]<link rel="canonical" href="http://www.example.com/forum/"> in your HTMLheaders telling the spiders which one to index. Please research this and don't just blindly copy my sample. I'm taking a 5 minute break from work and so I am replying off the top of my head.
(2013-05-24, 05:06 PM)laie_techie Wrote: [ -> ]The code I posted last should go in a .htaccess file in your DOC_ROOT to rewrite EVERYTHING to use www. DOC_ROOT is the folder on your server which is served as http://www.example.com/ . Domain only contains the name of the server; it does not include any folders.

As to http://www.example.com/forum/index.php redirecting to http://www.example.com/forum/ for SEO (Search Engine Optimization) purposes, you may want to include something like [i]<link rel="canonical" href="http://www.example.com/forum/"> in your HTMLheaders telling the spiders which one to index. Please research this and don't just blindly copy my sample. I'm taking a 5 minute break from work and so I am replying off the top of my head.

Thanks so much for replying, I really appreciate it. I'm trying to research this before I posted the original message but I get different answers as to what code to use, and the issue is complicated by us using a folder to host the forum.

If there's one thing that I worry about, is the .htaccess because bad code there can sink your site in terms of SEO. Google is already spending just about the 24 hours of the day spidering the forum and we know G is loving us already from our GWT data. But we need to have this whole www. and no-www. issue asap because the more threads and bigger the forum, the more the SEO impact.

About canonical URLS, shal I place the canonical tag ONLY in the pages that are duplicate? For example, for

example.com/forum/index

Shall I place the canonical tag there so it links to

www.example.com/forum/

I'm reading on canonical tags as we speak, but it seems there's a lot of confusion on the subject. I'd prefer to simply 301 all these duplicate pages. Google is now displaying both the example.com/forum/ and www.example.com/forum/ and this is not good. We have already set the preferred domain for incoming links, but this is not enough.

Can I ask, is there a reason why only one forum member is kindly helping me out?

Is my issue that big that it is beyond most people's knowledge, or is there an issue with my forum that is breaking a rule? I believe I'm following the rules and our forum is about as clean and well-intentioned as it could be.

Perhaps my question has been repeated ad nauseum? I researched this topic prior to posting the question as I could not find any specific answers to our issue. In fact, I'm sure this thread will help other people in the future.

Please let me know and I'll happily fix anything if it is on our part. I just don't know why no one else is offering their help despite this forum is full of very-knowledgeable people.

Thanks
No... We just don't all need to jump in to help someone. We usually let the first member that jumps to it solve it. I would've helped you fix it, but I was busy playing Portal 2 Toungue

MyBB has a good Support Community, we just know that we don't all have to jump in.
Pages: 1 2