Hello, I have actually been trying to solve this problem for over a month, to no avail.

I am trying to create a group of websites with Drupal 7, using multisite.

Drupal core is installed at example1.com, and I have a multisite setup for example2.com. For some reason, example2.com isn't using .htaccess, and thus Clean URLs do not work on example2.com. I get the 'The clean URL test failed.' message when trying to enable them on example2.com. I know that example2.com doesn't recognize htaccess because when I add some random garbage to htaccess, example2.com doesn't get affected, however example1.com gets an Internet Server Error.

I am NOT using a smylink. I have Drupal core installed at /var/www/example1.com, and example2.com points to example1.com's root directory from the httpd conf file.

Has anyone got any tips or potential solutions I could try?! I'm desperate for anything!

Thank you,
kitzinger

Comments

John_B’s picture

Make sure the paths in .htaccess are right https://www.drupal.org/node/239583#comment-786932

Not sure if you need to set up the URLs in Apache as aliases rather than their own virtual hosts. You could look here https://www.drupal.org/node/25011#comment-136227. Anyway be sure that all virtual hosts have Allow Override All http://drupal.stackexchange.com/questions/63931/drupal-7-multisite-not-p...

I long ago gave up on mutlisite (a very controversial subject, many people find it more trouble than it is worth but others are heavily invested in this type of setup).

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

kitzinger’s picture

Thanks Johnb, but what might the Alias look like in the conf file?

Currently each domain has its own virtualhost, how would I make an alias correctly? Alias /var/www/example2.com /var/www/example1.com ???

Thank you!

John_B’s picture

TBH I do not know for sure whether you absolutely need to use aliases with multisite: best check some tutorials. One of the links I gave you shows the set up already.

In case that is not clear, generally if you are configuring Apache manually, rather than using a control panel, the best place to look is on the Apache documentation, which is not too difficult to follow http://httpd.apache.org/docs/2.2/vhosts/name-based.html.

Note that there are small differences if you are using Apache 2.4 rather than 2.2, be sure to use the correct docs., not that I think there is a difference here. Note also, if Googling for it, that Apache aliases using mod_alias are not the same Apache ServerAlias, which is what we are talking about here.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

kitzinger’s picture

Thanks ever so much for the input John, however I just want to clarify a few things and wonder if you could perhaps shed some more light on what might be happening.

I have taken a look at the posts you referenced, and the answers look good, but the main problem is that they are serving sites from subdomains or subdirectories, whereas I want to serve them from independent URLs.

I have multisite working OK, the only problem is that the multisites aren't using the main site's htaccess file, which means I can't use Clean URLs.

example1.com is the main site, and example2.com is the multisite.

This is my configuration in the httpd conf files:

<VirtualHost *:80>
    ServerName www.example1.com
    ServerAlias example1.com
    DocumentRoot /var/www/vhosts/example1.com/httpdocs
    <Directory "/var/www/vhosts/example1.com/httpdocs">
        AllowOverride All
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName www.example2.com
    ServerAlias example2.com
    DocumentRoot /var/www/vhosts/example1.com/httpdocs
    <Directory "/var/www/vhosts/example2.com/httpdocs">
        AllowOverride All
    </Directory>
</VirtualHost>

I have the DocumentRoot for example2.com pointing to example1.com, because that is where Drupal core is installed. I'm just using the default htaccess in example1.com's document root, I don't believe I can modify it like in the posts you linked because the multisites aren't using subdirectories (like /drupal/, /secondsite/), but independent domain names. When I add a string of garbage text to the htaccess file, example1.com goes offline, but example2.com stays online. That's because example1.com is using htaccess, whereas example2.com doesn't even recognize htaccess, therefore isn't using it for any services like Clean URLs, unfortunately.

I wonder if you have any inclination as to what my problem could be or how to resolve it? I do want to use multisites because the design, content, and layout of the two sites are very similar, just on slightly different topics. Is there possibly something else you think I might be able to try?

John_B’s picture

First I was wrong to think you need to ServerAlias i.e. name-based virtual hosts for multisite. It is optional. You are not using them.

Second, if you carefully scan the config you posted you will see a typo.

line 12 is <Directory "/var/www/vhosts/example2.com/httpdocs">
should be <Directory "/var/www/vhosts/example1.com/httpdocs">

remember to restart apache after adjusting!

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

kitzinger’s picture

Thanks John.

I made the change, restarted apache, but no progress... there's no change.
Any ideas?

What could possibly be causing example2.com not to use htaccess even though the DocumentRoot is for example1.com, where htaccess is located??

Thanks again

John_B’s picture

I don't know. You are not the first to have this trouble. As I said, a whole raft of problems led me to give up on multisite, though there are rare times when it is the right choice. I have had enough problems with Clean URLs on non-multisite... Always works in the end though.

The next thing I would check is that you are starting with unmodified .htaccess (no rewrite base or anything of that kind, just the file exactly as it came from drupal.org), because the default www rewrite (which will be commented out in an unmodified .hataccess) does not work: https://www.drupal.org/node/93603. Then experiment with rewrite base and maybe some specific rules. The guy with the accepted answer here http://stackoverflow.com/questions/16595392/clean-url-test-failed-d7 got it working. I know you are working on the theory that one of the sites is immune to .htaccess - I would not be so sure. If it is really not allowing override, there is something wrong with the Apache setup.

BTW for greater speed I do AllowOverride none, and include the .htaccess as part of the .conf file, as in
example.conf

<Directory /home/example/public_html>
AllowOverride None
Include /home/example/public_html/.htaccess
</Directory>

However, this alone is insecure as there are other .htaccess files in your Drupal folders for security, which should also be included if you are working that way.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors

kitzinger’s picture

Hi John,

I just wanted to let you know that I've made some sort of breakthrough, but wonder if I could pick your brains once more! You have been very helpful and I'm really grateful that you've offered some of your time to help me resolve this.

After replacing the htaccess file with the default Drupal version, both multisites now use htaccess. You were right, the second site is not immune to htaccess, or at least it isn't now. I added a string of garbage to the beginning to htaccess again, and both sites gave an Internal Server Error. Previously, just the main site gave the error.

However, when running the Clean URLs test on the second site, it still says that the Clean URL test failed. So I'm wondering whether there is something I can do to get that second site to also use Clean URLs now that I know htaccess is being read from both domains.

Any thoughts?

Thanks again

kitzinger’s picture

I fixed the problem! Thanks for the help John.

Here are the steps I used:

1. Replaced .htaccess file with the default Drupal version. I had uncommented some rewrite lines in .htaccess to force non-WWW to be redirected to WWW-only. When I replaced .htaccess with the default Drupal version, these lines were still commented.

2. I couldn't enable Clean URLs from the /?q=admin/etcetc URL, as I got a 'Clean URLs test failed' message. However, when I visited /admin/config/search/clean-urls, I was successfully able to enable them.

I'm still confused as to what actually resolved the problem, but it's now solved, and I'm so pleased that I can finally begin working on the site! Thanks again for all the help!

John_B’s picture

Glad it works. I have seen that fix work myself, I have no idea why. Sorry I forgot about it.

Digit Professionals specialising in Drupal, WordPress & CiviCRM support for publishers in non-profit and related sectors