I think this may have something to do with the settings.php of my site,
But I'd like drupal to recognise mysite.com as the same site as www.mysite.com.

The reason is, the site directory is passworded, so I get prompted for a password twice if I change from www.mysite.com to mysite.com even though they are actually the same place and I'd like to only have to input this password once.

Does anybody have any idea what I can do to allow drupal to recognise www.mysite.com as the same place as mysite.com,

cheers.

Comments

doq’s picture

its not Drupal issue. its your browser issue. Try to use only one "domain". e.g. redirect from one to the other.

jo1ene’s picture

Talk to your hosting service about having one redirected to the other.

Advanced Web Design

rubenk’s picture

EDIT: This comment is ONLY applicable to Drupal version 4.7 and above. Not 4.6. SORRY about any confusion.

See this link. This was just worked out yesterday.
It's entitled Login and logout pb: inconsistent use of $base_url

http://drupal.org/node/56634

This is almost exactly what you are speaking of. Please note that if you don't want to patch then go here:
http://drupal.org/cvs?commit=29592

and click on the titles of the separate components and then click on the number next to the file (this will ensure you have the latest version of the file) you can save the file with the changes included rather than patching, etc.

pavlos’s picture

You can do this on your own by editing the .htaccess of drupal in the root directory of your drupal installation. Google can penalise you for duplicated content if you don't! I know it is silly but that's the way it does. This is a very important code to have in all drupal installations.

All my sites are hosted on Apache. Not sure if this works for other servers. You need to redirect all your non-www traffic (http://xyzdomain.com) to your www.xyzdomain.com

Near the bottom it says something like:

  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

</IfModule>

You need to add the following before the closing IfModule tag:

  # Redirect typeyourdomainhere.com to www.typeyourdomainhere.com
  RewriteCond %{HTTP_HOST} ^typeyourdomainhere.com 
  RewriteRule (.*) http://www.typeyourdomainhere.com/$1 [R=301,L]

</IfModule>
dashmug’s picture

How do I check if my site is already fine? If both URLs (with and without www) show the same results, does that mean my site is fine and wouldn't be penalised by Google?

By the way, I think http://no-www.org can be of some help here.

cmsproducer’s picture

You do not need to fight your host or mess with .htaccess with 301 redirects that will signal to google that the secondary URL is being retired (read on the significance of a 301 header)

It's a Drupal setting that you need to adjust/add.
Unless your host/DNS captures the address without www and points it to www...., when the request gets to drupal, it considers it to be a new URL and looks for settings for it in the sites folder. It might load a page without graphics or with error messages if it cannot locate some includes.

The most reliable fix is to create a new subfolder (name it the same as the URL you want to redirect) in the sites director and treat the second version of your url like a new site...
Copy the exact settings.php that was being used by the main site and point the base IRL of this new 'site' to the url of the main site...

This will enable Drupal to know that all incoming request for either version of the URL are for the main site.

In this way, the second URL is immediately pointed to the main URL and Google will not see your pages as a duplicate site / URL.
That is how I have implemented www.cmsproducer.com and cmsproducer.com

-----
iDonny - Web CMS Development, Design, and Web Marketing Advice

Chaos_Zeus’s picture

This works ok, but there is still two separate "login" cookies maintained, one for www.mysite.com and mysite.com. So, on the first content added, it is redirected to the web page that is expressed with the $base_url.

rubenk’s picture

I finally figured out how to do a redirect while using a multi-site drupal installation: code is as follows

RewriteCond %{HTTP_HOST} ^(namesiteA\.org|namesiteB\.org|namesiteC\.org)$ [NC]
RewriteRule (.*) http://www.%1/$1 [R=301,L]

Thank you Markus.
See here for more info:
http://drupal.org/node/56634#comment-89285

markus_petrux’s picture

...it keeping the rest of the path intact.

Good catch! ;-)

Though, that way they may not notice the difference and still keep the "bad" URL bookmarked, so that will make your server work a bit more...

If you do not use the $1 symbol, then they will be redirected to the home page, maybe forcing them to update the bookmarks, maybe not...

Doubt is the beginning, not the end of wisdom.

Chaos_Zeus’s picture

DO you need both the patch and the .htaccess changes? Is there any way to do this without modifying the htaccess file?

I am using Drupal 7.2, and looking at the patch file it appears to be patched as above.