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 www.forum.example.com to forum.example.com?
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 www.forum.example.com to forum.example.com?
Thanks.
1
Answers
Just do a dns CNAME with the www to forum.example.com.
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 — http://www.groups.google.com/ redirects to http://groups.google.com/
So, I would like to implement it too.
I did try that. It wasn't redirecting.
You need to remove the old www.forum.example.com 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: http://www.affiliatebeginnersguide.com/domains/redirection.html
@luc : Okay, I will check it again now. But before that — is CNAME redirecting www.forum.example.com to forum.example.com enough? Does it account to 301 redirection?
Or should I also add those .htaccess rules alongside CNAME-ing?
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".
This is the appropriate one, and using it breaks the friendly links on my forum:
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!
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.
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.