SMF Support > Server Performance and Configuration
Non WWW to WWW
imi82:
I used this and works perfectly with all sort of redirection.
--- Code: ---RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yoursite\.com [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [R=301,L]
--- End code ---
I use SMFpacks SEO for setting pretty urls and I put the mentioned code at the top of the .htaccess file before all the other codes. I hope this will help.
MrPhil:
That's the reverse of what was requested. Your code changes www.yoursite.com to yoursite.com, when the request was for yoursite.com to www.yoursite.com.
Luka Paunović:
Damn, do not open old topic, lock this...
johnpaul2k2:
each time i add any of these codes in my cpanel. i will be unable to access my main smf admin dashboard. i have tested almost all the codes yet i cannot access my forum as an admin. my password will stop working .but once i removed it, everything will come back to normal
Luka Paunović:
This is how I fixed this stupid little problem.
You need to place rewrite rule to TOP of .htaccess file
and here is a proper code for NON WWW to WWW redirect
--- Code: ---RewriteCond %{HTTP_HOST} ^yoursite.com$
RewriteRule ^(.*)$ "http\:\/\/www\.yoursite\.com\/$1" [R=301,L]
--- End code ---
Just remove all you did in .htaccess about this non www to www problem and put this code and it works like a charm :)
It will redirect
http://yoursite.com to http://www.yoursite.com
http://yoursite.com/any-link to http://www.yoursite.com/any-link
http://yoursite.com/any-link/blah-blah to http://www.yoursite.com/any-link/blah-blah
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version