Reputation: 1325
I have 2 domains:
gyanplease.com/gyanplease
primary domain (I have changed the document root with the help of .htaccess
)mobiledevsolutions.com
secondary domainOn the document root I have created a folder called gyanplease
and with the help of .htaccess
I have rewritten gyanplease.com
to the gyanplease
the folder. This the code for the redirection:
#disable https
RewriteEngine on
RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !gyanplease/
RewriteRule (.*) /gyanplease/$1 [L]
Now when I'm hosting another domain on the same server, that is mobiledevsolutions.com
, then it's not working and gives a 404 redirection error.
Upvotes: 2
Views: 79
Reputation:
What you can do is only run the /gyanplease/
rewrite for that host, like this (replacing the last two lines):
RewriteCond %{HTTP_HOST} (?:^|\.)gyanplease.com$
RewriteCond %{REQUEST_URI} !^/gyanplease/
RewriteRule ^(.*)$ /gyanplease/$1 [L]
That way this rule will only affect gyanplease.com
.
You can also change line 4 to this, since the capturing is not being used:
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
So all that would make your new rules:
RewriteEngine on
# Disable HTTPS
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Rewrite gyanplease.com to /gyanplease/
RewriteCond %{HTTP_HOST} (?:^|\.)gyanplease.com$
RewriteCond %{REQUEST_URI} !^/gyanplease/
RewriteRule ^(.*)$ /gyanplease/$1 [L]
Upvotes: 1