user116032 user116032 - 1 year ago 90
HTML Question

Site access via v/s is causing problems with sessions

I have a site at godaddy. You may access it using a www prefix or not. It works fine either way UNLESS you happen to hit a link that uses/does not use the prefix. Then the session disappears. Is supposed to be the same as If not, how do require the use of one or the other?

Answer Source

For usability (this problem) and SEO reasons you should redirect all visitors to a single version of the site. Look in the .htaccess file and you should see instructions on how to do a 301 redirect to send people to either the www or the non-www version of the site.

Make sure to place the .htaccess file you build in the root directory of your web site.

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

Here are the three lines of code to use if you want to drop the www.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$$1 [R=301,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download