views:

40

answers:

1

I have the following code in my Root htaccess file

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

It works fine for the main site, but for my forums at /forums/ if someone misses off the www it will show the page and not redirect to the www.paperviewmagazine.com/forums/ instead.

I need to force the WWW to prevent anyone from logging in by accident on the non-www as it wont have the correct cookie credentials for accessing the site at www./forums/

Can anyone help?

Thanks.

A: 

If you are just trying to route "site.com" to "www.site.com" then do:

RewriteCond %{HTTP_HOST}   !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST}   !^$
RewriteRule ^/?(.*)         http://www.example.com/$1 [L,R=301,NE]
webdestroya
Doesn't work on the forums though as I can still access them without the WWW here: http://paperviewmagazine.com/forums/
Cameron
Have you added `RewriteEngine On` ?
webdestroya
Yes the RewriteEngine is on.
Cameron
I should note that /forums has its own .htaccess file but has no rewrite code that changes the URL. Would it be possible to add some code to this htaccess file that forces the WWW when someone accesses the /forums directory. Thanks.
Cameron
Any updates on this?
Cameron
To be honest, it sounds like your server is totally disregarding the .htaccess files. Are you sure your server has read permissions to the files and all?
webdestroya
Nope because it's using the Htaccess file for the main website its just not filtering down to the /forums/ directory.
Cameron