Forum Moderators: phranque
I've found a few solutions to map a domain to a subdirectory (domainB is mapped to domainA/subfolder) on the Web and on this forum, and it's been working great except for two minor bugs I'd like to solve:
* Accessing domainB/subfolder/ still works
* Accessing domainB/anyfolder maps to domainB/subfolder/anyfolder, however domainB/anyfolder/ (with a slash at the end) works fine.
My filesystem is laid out as follows:
/
¦- .htaccess
¦- blog/ -(symlink)-> drupal/
¦- drupal/
¦--- <drupal installation here>
¦- web1/ -(symlink)-> drupal/
¦- web2/ -(symlink)-> drupal/ I've setup the required folders with drupal, so all is working there. Below is my .htaccess file:
Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#
# If we're not domainB and accessing /blog, redirect accordingly
#
RewriteCond %{HTTP_HOST} ^!domainB
RewriteCond %{REQUEST_URI} ^/blog/
RewriteRule ^blog/(.*)$ http://domainB.com/$1 [L,R=301]
#
# /X is really /blog/X on the filesystem
#
RewriteCond %{HTTP_HOST} ^domainB
RewriteCond %{REQUEST_URI} !^/blog/
RewriteRule ^(.*)$ /blog/$1 [L]
</IfModule>
RewriteCond %{REQUEST_URI} !^/blog/
Thanks in advance for any help!
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /blog.*\ HTTP/
RewriteRule ^blog/(.*)$ http://127.0.0.1/$1 [R=301,L]
This rule works perfectly, but what is odd is that if I rename htaccess.txt to .htaccess in /drupal, it stops working and /downloads for example expands to /blog/downloads and domainB/blog/ will not shorten to domainB. If I set "RewriteEngine off" in /drupal/.htaccess, then it starts working well again.
Edit: I see a similar problem with the "site1" and "site2" folders. I have a simple rule that redirects all non-www domains to their www ones, however typing "domainA.com/web1" gives me the Drupal installation page instead of adding the www first, so that drupal recognizes the site.