Solution multisite htaccess cleanURL

My solution to getting Clean URL working with my multisite setup drupal

I added Alias to my httpd.conf apache file

 

<VirtualHost *:80>
    # Alias for all php drupal sites
    Alias /abc /var/www/html/drupal
    Alias /def /var/www/html/drupal
    Alias /xyz /var/www/html/drupal
</VirtualHost>

My setup has 4 sites /drupal, /abc, /def, /xyz all files are in the /drupal directory

  • url=/drupal (sites/default/)
  • url=/abc (sites/localhost.abc/)
  • url=/def (sites/localhost.def/)
  • url=/xyz (sites/localhost.xyz/)

In the /drupal/.htacess file. I added a RewriteCond %{REQUEST_URI} condition for
each site, and so have separate RewriteRule for each site.
No need for the RewriteBase directive, leave it commented out

 

  #RewriteBase /drupal  DO NOT NEED THIS, COMMENT OUT

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/drupal/(.*)$
  RewriteRule ^(.*)$ /drupal/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/abc/(.*)$
  RewriteRule ^(.*)$ /abc/index.php?q=$1 [L,QSA]
 
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/def/(.*)$
  RewriteRule ^(.*)$ /def/index.php?q=$1 [L,QSA]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} ^/xyz/(.*)$
  RewriteRule ^(.*)$ /xyz/index.php?q=$1 [L,QSA]

Note: each site has its own database aswell as files, modules and themes directories in the corresponding sites/localhost.site/ directory.

 

solution two:

# If your site is running in a VirtualDocumentRoot at http://xxx.com/,
# uncomment the following line:
RewriteBase /

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
### THIS IS THE HOLY LINE
RewriteCond %{REQUEST_URI} !^/YOUR_SUBDIRECTORY/(.*)$
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/YOUR_SUBDIRECTORY/(.*)$
RewriteRule ^(.*)$ /YOUR_SUBDIRECTORY/index.php?q=$1 [L,QSA]

你可能感兴趣的:(Access)