News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Non WWW to WWW

Started by SimpleGost, June 06, 2012, 04:22:02 PM

Previous topic - Next topic

imi82

I used this and works perfectly with all sort of redirection.
RewriteEngine On
RewriteCond  %{HTTP_HOST}  ^www.yoursite\.com  [NC]
RewriteRule  ^(.*)$  http://yoursite.com/$1  [R=301,L]


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.

SimpleGost

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

SimpleGost

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


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


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

johnpaul2k2

still can't work . but these are my little observations

1. my forum url still topnichez.com/index.php how should i write it?or should i remove index.php first??
2. i have uninstalled Pretty url a while ago but it is still in my .htaccess



is it the cause

SimpleGost

Quote from: johnpaul2k2 on November 17, 2012, 01:39:40 AM
still can't work . but these are my little observations

1. my forum url still topnichez.com/index.php how should i write it?or should i remove index.php first??
2. i have uninstalled Pretty url a while ago but it is still in my .htaccess



is it the cause

Code which I gave you above needs to be on the TOP of .htaccess file!
And you need to change forum url to www if it isn't in configuration in admin panel.

johnpaul2k2

this is what i did

Edit settings.php and search for $boardurl =

edit ur url to contain www      and it's working


do i still need to paste this code???



SimpleGost

Quote from: johnpaul2k2 on November 18, 2012, 11:19:07 AM
this is what i did

Edit settings.php and search for $boardurl =

edit ur url to contain www      and it's working


do i still need to paste this code???

Yes you need because on some url-s it will not redirect from non www to www

johnpaul2k2

i have done everything but please why is it showing me this

Kill Em All

Make sure your browser accepts cookies or has them enabled.

You can read more info about the cookies and session id here:
http://www.simplemachines.org/community/index.php?topic=436791.msg3067263#msg3067263


My Site: KEAGaming.com

Manual Installation of Mods
Prevent Spam and Forum Attacks
Please do not PM or email me for support unless offered, help should be publicly displayed to others.

SimpleGost

Quote from: johnpaul2k2 on November 20, 2012, 01:57:32 AM
i have done everything but please why is it showing me this


Just clear your browser cache ;)
And as I mentioned code need to be on the top of .htaccess file!
I need to repeat 1000 times that :D

johnpaul2k2

 
Quote from: Luka Paunović on November 21, 2012, 03:33:53 PM
Quote from: johnpaul2k2 on November 20, 2012, 01:57:32 AM
i have done everything but please why is it showing me this


Just clear your browser cache ;)
And as I mentioned code need to be on the top of .htaccess file!
I need to repeat 1000 times that :D

i have cleared my browser cache, infact formatted my system but this code couldn't just go!!
is there any other thing i can do?? :(

SimpleGost

Quote from: johnpaul2k2 on January 08, 2013, 06:12:40 AM
Quote from: Luka Paunović on November 21, 2012, 03:33:53 PM
Quote from: johnpaul2k2 on November 20, 2012, 01:57:32 AM
i have done everything but please why is it showing me this


Just clear your browser cache ;)
And as I mentioned code need to be on the top of .htaccess file!
I need to repeat 1000 times that :D

i have cleared my browser cache, infact formatted my system but this code couldn't just go!!
is there any other thing i can do?? :(


I do not have that "problem"

Advertisement: