Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Redirect Users to www version of forum from non-www version

aeryaery Gtricks Forum in 2.2 :) ✭✭✭
edited May 2011 in Vanilla 2.0 - 2.8
My forum is located at www.gtricks.com/forum but normally without www version also works fine i.e. http://gtricks.com/forum.

Now, there are two problems. 1) Facebook integration works with only www version for I have specified www version in App settings. 2) There are two canonical URLS for same page.

I want to migrate non-www users to www site. A 301 redirect to be precise. An .htaccess edit has to be written, but unfortunately I font know the rules.

According to my understanding, it should be

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

but vanilla is in subfolder named forum and at root there is blog at www.gtricks.com.

Any advice on someone will be highly helpful.

So what should I write in my htaccess?

There was an error rendering this rich post.

Comments

  • I think you're backwards. It looks like you're looking for the www version and redirecting them to the non-www version. I actually prefer the non-www version, but that's just me.

    Here's mine that redirects anything that doesn't start with www -> the www version.

    RewriteEngine On RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule (.*) http://www.example.com/$1 [R=301,L]
  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭
    Thanks @Nutt for the quick reply.

    I already have the following rewrite code in htaccess.

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]

    After appending your code, the forum has started to act slow. Firefox keeps on showing connecting...connecting...

    And should we need to modify anything coz forum is located in sub-folder. The code is for root level sites. My root has gtricks blog and not forum

    There was an error rendering this rich post.

Sign In or Register to comment.