I described my problem here, here and here and searched for help in IRC - but got no answers since 17 days. I want to start playing with Drupal, but can't, until I know, that it will work.

Very briefly:

I want to redirect all my sites (of my multi-site) from www. to non-www.

It works for all the multi-sites (with this code) but not for the main site (default, where Drupal is installed). I can't access this default site anymore, as soon as I use the linked code snippet in my .htaccess.

It would be okay to waive the rewrite for the default site (means: It's okay to use the www-version for the default site only, if its eases things up), but I need to access the default site.

Pleease, any help?

Comments

no2e’s picture

The default site is http://example.com/john/drupal/ and when I use the linked snippet, it redirects me to http://example.com/, as soon as I try to call the site with www. (so as soon as I call http://www.example.com/john/drupal/

runssl’s picture

I have never used multi site but did you set
RewriteBase /john/drupal in your htaccess?

If you give me more examples I think I can help. Such as what are all the URLS in question.

Discount SSL Certificates http://www.RunSSL.com

no2e’s picture

did you set RewriteBase /john/drupal in your htaccess?

Yes, while testing, I set the RewriteBase to /john/drupal, but it didn't seem to change anything.

If you give me more examples I think I can help. Such as what are all the URLS in question.

At the moment, it's all under the same domain.

Default site (where Drupal is installed):

  • example.com/john/drupal

Multi-Sites:

  • foobar.example.com
  • acme.example.com/alice
  • and more multisites of the same structure ("subdomain" or "subdomain + subdirectory")
dnewkerk’s picture

It's not as fancy a technique as what you appear to be using with that code, but in my case, I just copy/pasted multiple copies of the www/non-www related RewriteCond and RewriteRule lines in .htaccess, and changed the domain names in the second copy. Works fine for me (one site is the default site, and there is 1 multi-site).

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

no2e’s picture

I just copy/pasted multiple copies of the www/non-www related RewriteCond and RewriteRule lines in .htaccess, and changed the domain names in the second copy.

That would be okay for me (don't have many multisites, so manually editing would be no problem).

Can you tell me, how exactly the snippets should look like? (I posted the site/url structure above)
And in what order I have to arrange them?

I don't know, if I have to use

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

or

RewriteCond %{HTTP_HOST} ^www\.example\.com/john/drupal/$ [NC]
RewriteRule ^(.*)$ http://example.com/john/drupal/$1 [L,R=301]

for the default site.

----
/bump :|

dnewkerk’s picture

I'm afraid I don't know either. I haven't installed Drupal in a sub-folder since I first tried it out with Drupal 4.7, and then I didn't adjust the www/non-www settings. I only use Drupal now at the root of the domain, or as a sub-domain sometimes.

My instinct is that you don't include that full path there in the rewrite rules, but I could be wrong. My limited understanding of what Apache is doing there is it is receiving that URL, checking it against the pattern you've provided (which I believe is a regular expression), and if it matches what it's looking for, either process it a certain way, or pass it on as is.

One setting which I also have never used, but seems worth checking as well is $base_url in your sites/default/settings.php file. Check that out if you haven't already. I also have never uncommented RewriteBase in my .htaccess

Anyhow, hope this helps at least a little. Keep in mind the apache rewrite stuff is also a general hosting sort of question too, so you might get help on it as well from webhostingtalk or places like that.

Good luck.

-- David
davidnewkerk.com | absolutecross.com
View my Drupal lessons & guides

no2e’s picture

I'm afraid I don't know either.

Hum, okay - thanks anyway.

One setting which I also have never used, but seems worth checking as well is $base_url in your sites/default/settings.php file. Check that out if you haven't already.

I set $base_url for my default site (http://example.com/john/drupal/) to http://example.com/john/drupal. I did not set it for any multi site.

no2e’s picture

When I use

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

in the .htaccess of my installation (in /john/drupal),
it redirects all my multisite subdomains correctly.
But the default site only works when I call it without www.. When I enter the URL with the www-prefix, I get redirected to http://example.com, but with the correct url suffixes.
So let's say, I call http://www.example.com/john/drupal/admin. I'll get redirected to http://example.com/admin

So I thought, it's because of the missing RewriteBase in the .htaccess - but after setting it to /john/drupal, the Clean URLs do not work anymore for any of my multisites.