Page 1 of 1

Don't mix WWW and without!

PostPosted: October 24th, 2010, 3:02 am
by Jason Caldwell
Some site owners don't realize that ALL browsers consider variations in your domain as "different". That is, EVERY browser sees each of these URLs as totally different destinations:
Code: Select all
http://example.com/
http://www.example.com/
For this reason, most site owners implement .htaccess tricks to force one version or the other, so that a visitor could type either into their address bar, yet still end up in the right place.

Concerning the s2Member plugin for WordPress®:

If a Member logs in at: ( NOTICE the www. prefix )
Code: Select all
http://www.example.com/wp-login.php
their login Cookie will ONLY be recognized on that particular variation of your site.

Now, if you created a link to: ( WITHOUT the www. prefix )
Code: Select all
http://example.com/category/juices/
they would NOT be recognized as a logged-in Member, because they originally logged in on another variation of your domain ( with the www. prefix ).

Decide which variation you're going to use:
Decide early-on which domain variation you're going to use, and make sure that your installation of WordPress® is configured to match what you intend to use. Check your Dashboard under: Settings -> General. All of the URLs configured in that panel, need to match what you intend to use.

Remain consistent: Be consistent in the way you link to pages on your site. Please do NOT create links on your site that use different variations of your domain. That could result in a visitor logging in on one variation, but clicking links on your site that land them on another variation ( where they may not be recognized as a logged-in Member ).

Related articles:
http://blog.stackoverflow.com/2008/06/d ... ww-prefix/
http://www.codinghorror.com/blog/2008/0 ... ebate.html
http://www.besthostratings.com/articles ... ccess.html
http://codex.wordpress.org/Changing_The_Site_URL

Forcing one or the other:
http://www.besthostratings.com/articles ... ccess.html

Re: Don't mix WWW and without!

PostPosted: October 29th, 2010, 10:50 pm
by chelle
Yes, everyone needs to read this first thing before they install s2member- I learned this the hard way...and probably am why you posted this :)

Re: Don't mix WWW and without!

PostPosted: November 24th, 2010, 9:10 am
by PorridgePot
same here. I spent a couple hours trying to figure out what was wrong.

Re: Don't mix WWW and without!

PostPosted: January 8th, 2011, 3:17 pm
by cdvrooman
How would you handle support for HTTPS?

For example, redirecting https://example.com to https://www.example.com?

Re: Don't mix WWW and without!

PostPosted: January 13th, 2011, 6:12 am
by Jason Caldwell
cdvrooman wrote:How would you handle support for HTTPS?

For example, redirecting https://example.com to https://www.example.com?

You might take a look here:
http://www.askapache.com/htaccess/ssl-e ... ccess.html

Re: Don't mix WWW and without!

PostPosted: January 26th, 2011, 5:24 pm
by james
Yup we've have all urls with www striped. Also, everyone should remember to set this in you google webmaster tools.

thanks

Re: Don't mix WWW and without!

PostPosted: February 13th, 2011, 1:20 am
by ThePick
Great post, Jason. I just spent a couple of hours ripping my hair out over this little issue and managed to figure out what the problem was after a lot of trial and error. It sure felt good when my Welcome Page finally popped up again after logging in.

Re: Don't mix WWW and without!

PostPosted: August 8th, 2011, 4:41 pm
by musickjl
Is there a good way to fix this problem? Since multi site automatically creates the subdomain without the www I now have hundreds of links that take me back to the login screen. Please help!

Re: Don't mix WWW and without!

PostPosted: August 8th, 2011, 11:56 pm
by Jason Caldwell
This post would normally NOT apply to a Multisite Network when you're running in sub-domain mode. When a Multisite Network is running with sub-domains, cookies are set for each sub-domain respectively, and the www issue is only relevant on the Main Site of the Network.

Re: Don't mix WWW and without!

PostPosted: August 9th, 2011, 9:13 am
by musickjl
That's correct, and I am only having issues with it on the main site. My problem is that I don't even need S2Member on my main site, only the subsite. Is there anyway to disable the plugin on the main site and only have it work on the subsite? This would solve my proglem. Thanks for your help!

Re: Don't mix WWW and without!

PostPosted: August 9th, 2011, 1:35 pm
by Cristián Lávaque
Just don't use in the main site, no restrictions, no buttons. Or do you mean not have it even active, or not showing in the plugins?

Re: Don't mix WWW and without!

PostPosted: August 9th, 2011, 1:50 pm
by musickjl
Correct, not having it as an active plugin on the main site, just the subsite. Thanks,

Re: Don't mix WWW and without!

PostPosted: August 9th, 2011, 9:08 pm
by Jason Caldwell
Excellent question. Thank you.
musickjl wrote:Correct, not having it as an active plugin on the main site, just the subsite. Thanks,
Unfortunately, a default installation of WordPress does not provide that ability in Multisite mode. However, one of these plugins may help you accomplish what you need to.

http://wordpress.org/extend/plugins/plugins-enabler/
http://wordpress.org/extend/plugins/exclude-plugins/
http://wordpress.org/extend/plugins/res ... e-plugins/
http://wordpress.org/extend/plugins/plu ... -networks/

Re: Don't mix WWW and without!

PostPosted: January 13th, 2012, 9:17 am
by duncanmajor
Thanks for this thread. In my case, adding www solved an error with my custom value domain name.