Rewrite to support folders as domain aliases while hiding subfolders
Posted
by
user1692328
on Stack Overflow
See other posts from Stack Overflow
or by user1692328
Published on 2012-09-23T15:35:25Z
Indexed on
2012/09/23
15:37 UTC
Read the original article
Hit count: 290
I am trying to use domain aliases to point to subfolders on my site where the subfolders name would be hidden from resulting url on rewrite. domain-alias1.com and domain-alias2.com are domain aliases to domain.com
I have the following in my root:
domain.com/
.htaccess (listed below)
domain-alias1/
main/
.htaccess (contains only Options -Indexes)
domain-alias2/
...
/.htaccess follows:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain-alias1\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.domain-alias1\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/domain-alias1
RewriteRule ^(.*)$ domain-alias1/$1 [L]
RewriteCond %{HTTP_HOST} ^domain-alias2\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\.domain-alias2\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/domain-alias2
RewriteRule ^(.*)$ domain-alias2/$1 [L]
domain-alias1.com (yields) -> Forbidden. You don't have permission to access /cogeco-gis/ on this server. (Which is what I want since .htaccess in domain.com/domain-alias1 contains Options -Indexes)
domain-alias1.com/test (yields) -> Not Found. The requested URL /domain-alias1/test was not found on this server. (Which is what I expect since test does not exist)
domain-alias1.com/main (yields) -> domain-alias1.com/domain-alias1/main/login_page.php
I am expecting rewrite to yield : domain-alias1.com/main/login_page.php where subfolder domain-alias1 is hidden from resulting url)
Any help on how to get expected results?
© Stack Overflow or respective owner