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.

How to redirect to

edited March 2012 in Vanilla 2.0 - 2.8

Hi, looking at this It's pretty clear that redirecting a Vanilla forum can be pretty tricky.

I have tried all sorts of redirection rules in my .htaccess file, but none works. How do I redirect to




  • lucluc ✭✭

    Just do a dns CNAME with the www to

    But more importantly is why you set this up in the first place, seems silly.

  • edited March 2012

    But more importantly is why you set this up in the first place, seems silly.

    My control panel did that automatically when I created the sub-domain. I felt further intrigued when I found out that even Google does it — redirects to

    So, I would like to implement it too.

    Just do a dns CNAME with the www to

    I did try that. It wasn't redirecting.

  • lucluc ✭✭
    edited March 2012

    You need to remove the old dns entry first also.
    But anyway, it was a wrong tip, it won't change the http request, just go to the same server.

    As for the .htaccess for this, I guess google got many examples on how to change the host automatically.
    for instance:

  • @luc : Okay, I will check it again now. But before that — is CNAME redirecting to enough? Does it account to 301 redirection?

    Or should I also add those .htaccess rules alongside CNAME-ing?

  • lucluc ✭✭

    I edited my answer (I guess, after you read it).

    Except if it's widely available already, it might even be a good idea to remove that dns entry with the "www".

  • edited March 2012

    This is the appropriate one, and using it breaks the friendly links on my forum:

    #Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{http_host} ^
    RewriteRule ^(.*)$1 [R=301,L]

    As @x00 suggested here, it could be an issue with the routes. Can you modify the routes in x00's answer to suite this one? Thanks!

  • lucluc ✭✭

    You don't put just this, that's just the first part, once it's rewritten, you put the rest of the rewrite rules for friendly links and such.
    I think you need to remove the 'L' on your last line, I think it's for "Last", hence stopping any further rewrites.

    Not too sure though, I'm not using apache but nginx.

  • edited March 2012

    I think I got it! Here's how the final .htaccess file should look like (I have commented clearly so that it helps anyone willing to do the same).

    NOTE: This only applies to those who have Vanilla installed on a sub-directory.

    #Redirects www sub-domain to non-www version
    RewriteEngine On
    RewriteCond %{http_host} ^
    RewriteRule ^(.*)?$1?redirected [R=301,L]
    #Redirects sub-directory to sub-domain
    RedirectMatch 301 /forum(/.*)?$1?redirected
    # Modified
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
       RewriteEngine On
       # Certain hosts may require the following line.
       # If vanilla is in a subfolder then you need to specify it after the /. 
       # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
       # RewriteBase /
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)$ index.php\?p=$1 [QSA,L]
Sign In or Register to comment.