Reputation: 1078
I need to use javasctipt to redirect to a URL
I currently use something like:
<SCRIPT language="JavaScript">
window.location="http://app1.mydomain.com/red";
</SCRIPT>
But now I need the redirect to be smart and go to a different executable based on the host.
Example
red.mydomain.com --> http://app1.mydomain.com/red
blue.mydomain.com --> http://app1.mydomain.com/blue
Further complicating matters I need the parameters to remain in tact.
blue.mydomain.com/?parameter1=abc?paramteter2=123 -->http://app1.mydomain.com/blue/?parameter1=abc?paramteter2=123
How does one "read" the in URL and do a case statement to branch it out?
How does one keep the paramter string so He can pass it in tact?
Upvotes: 2
Views: 171
Reputation:
Create two Sub domains Red and Blue and then You will have
red.example.com blue.example.com
Then In your .htacsess put in
RewriteCond %{HTTP_HOST} ^red\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.red\.example\.com$
RewriteRule ^/?$ "https\:\/\/example\.com\/red" [R=301,L]
RewriteCond %{HTTP_HOST} ^blue\.example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.blue\.example\.com$
RewriteRule ^/?$ "https\:\/\/example\.com\/blue" [R=301,L]
and now when someone now goes to red.mydomain.com they will be redirected to https://example.com/red before the page loads making the redirect faster than loading the page then redirecting them to then load another page.
I Hope this helps, Lewis
Upvotes: 1