Reputation: 145
I have a server e.g. 123.123.123.123 which has two URLs pointing to it
www.mysite.com and api.mysite.com
how do i make it such that www.mysite.com will redirect to 123.123.123.123/front while api.mysite.com will redirect to 123.123.123.123/api?
for www.mysite.com it shouldn't display www.mysite.com/front on the address bar.
Thanks in advance!
Upvotes: 1
Views: 82
Reputation: 145
Not very good with htaccess, but I managed to get it working with these:
RewriteCond %{HTTP_HOST} www.mysite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^mysite.com [NC]
RewriteRule ^(.*)$ front/$1 [L]
Upvotes: 0
Reputation: 785246
You can use these 2 rules in your site root .htaccess:
RewriteEngine On
# route www.example.com and example.com
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule !^front/ Front%{REQUEST_URI} [L,NC]
# route api.example.com
RewriteCond %{HTTP_HOST} ^api\.example\.com$ [NC]
RewriteRule !^api/ api%{REQUEST_URI} [L,NC]
RewriteRule !^front/
is matching a pattern using negative condition that means execute this rule if REQUEST_URI
doesn't start with /front/
Upvotes: 1
Reputation: 1791
A partial solution of your question could be as follows:
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^$ http://example.com/Front/index.php
Upvotes: 0