开发者

HTACCESS Rewrite on directories

I have the following code in my Root htaccess file

RewriteCond %{HTTP_HOST} ^paperviewmagazine.com RewriteRule (开发者_StackOverflow.*) 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.


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]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜