PDA

View Full Version : htaccess for forums



Arithan
12-29-2009, 01:29 AM
I currently have a forum on my site in its own directory: www.example.com/forums

I also have a subdomain that has that directory as its root: forums.example.com

I currently have this to get rid of the www like if someone types www.forums.example.com

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


But when I go to www.example.com/forums I can still access the forums. What do I have to do to make it so that when people go to www.example.com/forums it will redirect them to http://forums.example.com ?

MrDelish
12-30-2009, 10:26 AM
This is, apparently, the syntax that will redirect from www to non-www:

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

The following edited version may work:

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