When I configure a site with a subdirectory, say example.com/foo as an alias, foo.example.com site URI, i get a 404 when i visit example.com/foo/node.

The requested URL /var/aegir/hostmaster-6.x-2.0-rc2/index.php was not found on this server.

This was first reported in #2020079: Multi-server subdirectory support.

Comments

anarcat’s picture

I tried the following...

status quo

The current approach is to have the following vhost:

<VirtualHost *:80>

  ServerName example.com
  Include /var/aegir/config/server_master/apache/subdirs.d/example.com/*.conf
</VirtualHost>

And the following foo.conf file in subdirs.d:

Alias /foo /var/aegir/hostmater-6.x-2.0-rc2
<Location /foo>

  SetEnv db_type  mysqli
  SetEnv db_name  fooexamplecom
  SetEnv db_user  fooexamplecom
  SetEnv db_passwd  XXXXXXXXX
  SetEnv db_host  mysql.example.com
  SetEnv db_port  3306
</Location>

# Error handler for Drupal > 4.6.7
<Directory "/var/aegir/hostmaster-6.x-2.0-rc2/sites/foo.example.com/files">
  SetHandler This_is_a_Drupal_security_line_do_not_remove
</Directory>

# Prevent direct reading of files in the private dir.
# This is for Drupal7 compatibility, which would normally drop
# a .htaccess in those directories, but we explicitly ignore those
<Directory "/var/aegir/hostmaster-6.x-2.0-rc2/sites/foo.example.com/private/" >
   SetHandler This_is_a_Drupal_security_line_do_not_remove
   Deny from all
   Options None
   Options +FollowSymLinks
</Directory>

It turns out that the rewrite rules simply don't kick in and clean URLs effectively are broken.

add a document root

I then tried this:

<VirtualHost *:80>

  ServerName example.com
  Include /var/aegir/config/server_master/apache/subdirs.d/example.com/*.conf

  DocumentRoot /var/aegir/hostmaster-6.x-2.0-rc2
</VirtualHost>

But then everything would redirect to example.com/install.php.

symlink /foo

I tried the above docroot solution but with a symlink foo -> .. in the platform directory. No luck either.

anarcat’s picture

Title: subdirectory support is not working » clean_urls don't work well with subdirectory
anarcat’s picture

Status: Active » Fixed

alright, after re-reading the original implementation, it seems that i was missing a magic rewrite rule. i originally thought a RewriteBase could work, but they only work in a .htaccess or a block.

The magic bit missing was:

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^<?php print $platform_path; ?>/(.*)$ /<?php print $location; ?>/index.php?q=$1 [L,QSA]

committed and pushed. next step is to figure out multiserver support!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.