开发者

How do I set up Drupal in Multisite mode using Apache Alias Directive instead of symlinks?

I have successfully followed guides in Drupal's install.txt and a few stackoverflow posts to create a new site in another subfolder on the same host as my original (default) Drupal site in part by using a symlink from /bar/ to /foo/.

Original site 
example.com/foo/

Additional Drupal Site
example.com/bar/

This is working great. The problem I am facing is that we would prefer not to use a symlink to provide the redirection, due to the additional strain on the server caused by . Is it possible to accomplish the same thing using the Alias directive in Apache?

So f开发者_如何学运维ar we have an Alias directive set up to send all requests for /bar/ to /foo/ . This sends people to the original site, /foo/, not the new site /bar/. Otherwise the URL is written correctly. Are there some additional steps that need to be taken to make this method work?


If I understand your problem correctly, you would like to use one single Drupal installation for 2 different sites, in order to avoid having the source code twice on the file system.

The symbolic link seems to be a good solution. Why can't you use it? I didn't really understand what you mean by "additional strain".

I always thought that Drupal multisite system was based on the servername ($_SERVER['HTTP_HOST']) in order to switch correctly in your sites/ folder. But as both of your sites are running under the same domain (and sub-domain), Drupal will load the same settings.php file.

One solution, would be to add a bit of logic in your settings.php file. You could check $_SERVER["REQUEST_URI"] and see if it starts with /foo/ or with /bar/. You could then switch between 2 databases (one for each directory). In this switch or if statement, you'll also have to set your $base_url variable in order to get Drupal generating links correctly.

For the uploaded files, you'll also have to separate things. You could create the following :

  • sites/foo/files
  • sites/bar/files

In each database, you will be able to set the file system directory (Drupal's admin page will be under admin/settings/file-system).

Hope this might help you.

PS : I thought also about a Apache RewriteRule instead of a redirection, but it wouldn't work because Drupal would just generate links to the target directory, so users will be redirected by clicking on the first link they meet on the generated page :-(


Good news, everything works now! Our test server had some strange DNS setup which was interfering with the redirection rules. Neither Symlinks nor Apache Redirect Directives were passing data to Drupal correctly.

When we moved to another virtualhost with no extra DNS redirection everything worked fine, and Drupal worked whether we were using Symlnks or Apache Directives.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜