3
  • I open a browser, type "www(dot)mydomain(dot)com"
  • I login as an admin
  • I open a new tab, type "mydomain(dot)com". I'm logged out, and i can login as a different user..

It's weird. I can't find anything helpful on google (or i don't know the right search keywords). Does anyone here have any idea?

Thanks :)

2 Answers 2

5

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.

If you really really do want to make the site work on both versions, open your settings.php and find the line for $cookie_domain. Set it to be the "example.com" version and it should work.

4
  • Hi, thanks. I went to edit settings.php and saw $base_url commented out. I tried to uncomment it and tested, and it seemed to solve my problem
    – Bibokid
    Commented May 2, 2012 at 2:57
  • @Bibokid IF greggles has provide a 'correct' answer, remember to click the check on the anser to give credit.
    – Ashlar
    Commented May 2, 2012 at 3:42
  • 1
    If you can access the site with www or without the www (without the url in address bar being re-written) , you have only fixed part of your problem. Although the site works you should still consider setting it up so all url's are served via the www.hostname.com schema. This is a very important point for search engines: no duplicate pages. In most sites I setup, the non www address space is used for CDN purposes. Commented May 2, 2012 at 3:43
  • 1
    thanks guys. i am working on it. Greggles have already pointed it out but thanks to stefgosselin for giving another heads up!
    – Bibokid
    Commented May 2, 2012 at 6:27
1

Here's my .htaccess solution for www Resolve to Apache.

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 ^(.*)$ http://www.example.com/$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 ^(.*)$ http://example.com/$1 [R=301,L]
2
  • @Bibokid, Great try choosing the best answer if it works.
    – niksmac
    Commented May 2, 2012 at 6:30
  • This is only one possible way to solve it in Drupal and has the effect of redirecting all traffic to one version of the site. That may be desirable, but knowing all solutions is useful if this is not a desirable effect.
    – greggles
    Commented May 2, 2012 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.