4

In D7 Multisite, I'd like to use clean URLs. However, these sites share the same domain but have different folder names.

For example, the login pages would are currently

https://domain.ext/red/?q=user
https://domain.ext/pink/?q=user 
https://domain.ext/green/?q=user 
https://domain.ext/purple/?q=user

How might I set this up to allow clean urls and have login pages as such:

https://domain.ext/red/user
https://domain.ext/pink/user 
https://domain.ext/green/user 
https://domain.ext/purple/user

The .htaccess file is untouched. The apache config file /etc/httpd/conf.d/aliases.conf contains:

Alias /blue /var/www/html 
Alias /pink /var/www/html 

And inside of /var/www/html/sites/ I have folders

/var/www/html/sites/blue
/var/www/html/sites/pink

Can I accomplish this by editing the $baseurl in each settings.php file and adding a redirect per site in .htaccess?

2
  • Have you considered using a module like SubFolders Domains?
    – Darvanen
    May 4, 2015 at 14:31
  • For future projects perhaps, but I'd like to solve this particular problem (as a learning exercise).
    – Rick
    May 4, 2015 at 14:38

2 Answers 2

4
+50

think you will require a separate virtualhost entry for each of the sub-sites. That should direct visitors to the correct location and negate any need for redirection.

At the moment you're using aliases to effectively send all traffic to the same place, I think using virtualhosts will separate the traffic a bit better and help you turn on clean URLs.

I'm going to assume your core Drupal files are at /var/www/html.

  1. You definitely need to read the documentation in /var/www/html/sites/sites.php and set that up if you haven't already.
  2. You do need to set the $basepath in each site's settings.php
  3. In Apache it kind of depends what OS you're using but you basically want to turn on NameVirtualHost in Apache and then tell it where to send visitors:
    • Here's how to do it in Ubuntu
    • Here's how to do it in CentOS which probably also translates to RHEL/Fedora

Those links give the full setup, so you've probably already done the first few steps. Keep going down the page to find the Virtual Host section.

Finally, clean URLs need to be enabled in each of your sites, one by one.

2
  • Can you expandon on how you'd set this up?
    – Rick
    May 8, 2015 at 20:27
  • Sure, updated answer.
    – Darvanen
    May 9, 2015 at 2:15
1

If you'd enable clean URLs, and enable module Global Redirect, then this is one of the module's features you'd get (from its project page):

Checks if the Clean URLs feature is enabled and then checks the current URL is being accessed using the clean method rather than the 'unclean' method.

Wouldn't that be "a" possible alternative to consider to address your question? If not, please explain why not.

PS: maybe consider changing green or purple to blue in your question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.