Looking for the most transparent way (for the visitor) to be redirected to a subdomain from a page on the www site. IIS is the server. Example:
www.mywebsite.com/cars
---> cars.mywebsite.com
Any suggestions?
Looking for the most transparent way (for the visitor) to be redirected to a subdomain from a page on the www site. IIS is the server. Example:
www.mywebsite.com/cars
---> cars.mywebsite.com
Any suggestions?
Well, if you want the solution in javascript, then its pretty easy. Just find out the first JS file thats loaded and add this on the TOP
if(document.url == "www.mywebsite.com/cars")
window.location("cars.mywebsite.com");
Just mentioned since you've mentioned javascript and html in the tags...
Javascript might be a bit of a clunky solution.
I'd recommend you go with something on the server side that will be easier to maintain.
Put the following contents into the web.config file
<?xml version="1.0"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://cars.mywebsite.com" httpResponseStatus="Permanent" />
</system.webServer>
</configuration>
This probably won't work within visual studio's web server, but should be fine in IIS
In case you are looking for the redirect in IIS server, the answer may lie in this post:
imho htaccess would re-direct the user before any data is sent to the client.
Example: in teh root dir you want the user directed -from- place a file called .htaccess with the contents of:
#Redirect old file path to new file path
Redirect /olddirectory/oldfile.html http://cars.example.com/newdirectory/newfile.html
Source: http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
Hope that helps Kurt.
If you're looking for single solution - then @Riju's answer is a good one.
But for a more general solution, URL Rewriter for IIS is pretty powerful and will allow you to create rules things like this, and many more situations.