0

I have a shopping cart I'm implementing (well known company and a solid platform) -- it's based in PHP/Smarty.

Works great if I put www.foosite.com/store/ into my browser.

If I put foosite.com/store/ into the browser it is not populating saved cookie variables correctly. Also, I noticed that it prompts me twice on my .htaccess/.htpasswd block.

So, what is it about www. versus without that can cause such a dramatic difference in the behavior of a site? And is there a way to fix it?

C C
  • 419
  • 1
  • 4
  • 18

1 Answers1

1

well a solution to fix this would be to add in your htaccess a rewrite rule to force the 'www', something like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Julien
  • 2,217
  • 2
  • 28
  • 49
  • ok, cool - thanks. Is this kind of .htaccess fix something you guys deal with all the time as standard practice -- or in my case is it a "band-aid" fix for some design flaw in my site? – C C Jun 04 '13 at 17:53
  • I do use this trick in some of our websites that have the need to always be accessed with the 'www', but each case is different, in yours, well its hard to know without seeing your code, or how the platform that you use is implemented. regarding the cookies i'm guessing it has to do with the way their respective domain value is set (have a look here about that, there is a good answer http://stackoverflow.com/questions/1062963/how-do-browser-cookie-domains-work). – Julien Jun 04 '13 at 17:58