Posted by john in apache, programing
One of the sites that I’ve been working on recently for some odd reason would not log users in (or at least not constantly). After looking into it further, I realized it had to do with the PHP function “header” redirecting the user if the login query was successfully.
The problem came when a user came to the site without typing in “www”. The page was redirecting to the site WITH the “www” and the $_SESSION vars were not getting set.
So to force every page to include the “www”, I added the following 3 lines to the .htaccess file and everything seems to be working fine.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.domain.com$
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301]







November 9th, 2008 at 1:02 pm
Thanks! This was a huge help. Should have figured this one out on my own though!
[Reply]