Shared hosting: Clean URLs not working for additional sites

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
no2e's picture

Introduction

I just started my first multisite setup (on a shared hosting account).

The problem

Clean URLs work great for example.com/drupal.
But not for foobar.example.com; it says:

Your system configuration does not currently support this feature. The handbook page on Clean URLs has additional troubleshooting information.

The solution?

This book page exactly describes my problem. But I don't understand the suggested solution. Where and in what way do I have to edit the .htaccess?
In many other threads (and also in the comment of the linked page) it's said, that you have to edit the http.conf - but I'm not allowed to edit it at my shared hosting, I think.

Possible?

Comments

Update (1)

no2e's picture

It works ...

After butchering my .htaccess file, I started with the default one again, and - what shall I say - it works. Clean URLs work in my default and in my additional site.

... partly

But I had to deactivate the redirection from www. to no-www.
So, could someone help me?
What do I have to change, so that every site shall use only the version without the www-prefix? And where exactly do I have to place it in my .htaccess?

If it would ease things up: it would suffice, that only all additional sites use the URL structure withouth the www-subdomain. I can live with the default site using it, because it won't be public at all.

Additional questions (unrelated)

Got some questions wich are no own thread worth, I think.

Default install in subfolder, additonal site in root?

Is it possible, to install Drupal in example.com/drupal and to create a multisite for example.com?
So the sites structure would look like:

Or would that break something?

/EDIT: hum, never mind. I think it's not possible, because I can't tell example.com, that it shall look in example.com/drupal (which is possible for me only with domains and subdomains, I'm afraid).

$base_url

I shall edit in eachs multisite settings.php the $base_url, correct? So in the settings.php inside of /sites/foobar.example.com I set it to:

$base_url = 'http://foobar.example.com';  // NO trailing slash!

Should I edit it in the settings.php of /sites/default, too?

bump

no2e's picture

No idea? :/

How did you implement the www to non-www (or vice versa) redirects for your multisites?

Update (2)

no2e's picture

Okay, with this code (by open-keywords), www to non-www redirection works for my multisites:

# non empty HTTP_HOST in the request
        RewriteCond %{HTTP_HOST} !^$ [NC]
# the hostname does start with 'www.'
        RewriteCond %{HTTP_HOST} ^www. [NC]
# let's extract the hostname without 'www.' and save it to %1
        RewriteCond %{HTTP_HOST} ^www.(.)$ [NC]
# let's redirect to the extracted hostname, $1 saves the URL
        RewriteRule ^(.
)$ "http://%1/$1" [L,R=301]

... but not for my default/main site. The main site redirects from http://example.org/drupal (where Drupal is installed) to http://example.org/ (where no Drupal is installed).

... help? :|

Still need help

no2e's picture

Can't I express my problem clearly? (English is not my native language, as you might have guessed ;)
Please ask, if something is unclear. I need help.

Created another topic.

Hmm

macieq's picture

It is strage what u said.

In attachement i give u my settings.php on one my multi-ste.
There is enything special there... I think it is problem with configuration on your server. I suggest to ask server admin to check configuration of your domain. I'll try to help u.

I have 17 sites in my multi-site configuration and i hadn't problem with that. But we'll try.

Attachement missing?

no2e's picture

Thanks for your answer!
Can't find your attachement. Did you forget uploading it?
Am I getting you right: you also use www. to non-www. redirection/rewrite? (because that's actually my problem) Wouldn't I need a .htaccess example?

It is strage what u said.

I bet it's just me doing some stupid mistakes - don't know any details about .htaccess and stuff like that.

Okey

macieq's picture

Lets start. (examples in attachements) settings and .htaccess
All are default. Nothing special.
My configuration sample:

page.u-c.pl (main site)
-sites
- default (files to page.u-c.pl)
-settings.php

-chorwiwat.pl
-files
-modules
-settings.php

etc.

Hmm, you don't use www. to

no2e's picture

Hmm, you don't use www. to non-www redirection, do you? Because, that is actually my problem.

base_url

macieq's picture

Try to comment the base_url line in settings.php

In general: Should I use the

no2e's picture

In general:
Should I use the base_url setting in all of my settings.php, or in the default one only?
And if I should use it in all settings.php - how exactly should the setting look like for the multisite sites? (the URL where Drupal is installed, or the domain of the multisite?)

Okay, I'll comment the base_url setting for testing now.

/edit: didn't change anything. But the problem might be, that I don't know, what the correct way to solve my problem would be. So, I don't know which htaccess-settings should work.

.htaccess

macieq's picture

.htaccess shlould be default, and it should work with it. But In my case i have drupal site in main site directory. You have in /drupal directory and you shuld for settings write:

$base_url = 'http://www.example.com/drupal';

and if you tell me that when www is include there is problem with clean urls than you should edit the .htaccess and turn url check on to force non-www.

tell me if it is good

Multisite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: