Reputation: 678
So, I currently have a simple MVC web site sat on www.mysite.com and an installation of BlogEngine in a BLOG folder on the root.
my question is how, in code, can I redirect a hit on sub.mysite.com to display the blogengine site in the BLOG folder?
The sites are currently hosted with WinHost who have suggested using a simple VBScript (seen here). This is fine but I can't for the life of me figure out where to put it within the MVC site. The link says the "default" document, but is that wihin the body/head? everything I have tried hasn't worked.
I know things are all working on the host side of things as hitting sub.mysite.com simply displays the MVC site as it should.
I have also read about the rewrite module but I feel this isn't an option because of limitations with my host.
Any help would be super awesome!
EDIT: Following Dan Atkinson's post below I have accessed the IIS7 Rewrite Module and created the following rule:
Input URL path after ‘/’ Matches (.*) Redirect http://www.mysite.com/blog/{R:1} (Stop processing = true, entry type = local)
{HTTP_HOST} Matches the Pattern ^blog.mysite.com$
{REQUEST_URI} Matches the Pattern /blog
the XML for this rull looks like this:
<rule name="blog.mysite.com" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^blog.mysite.com$" />
<add input="{REQUEST_URI}" negate="true" pattern="/blog" />
</conditions>
<action type="Redirect" url="http://www.mysite.com/blog/{R:1}" />
</rule>
This still isn't working though and is still just defaulting to the root site..I feel we are close though! Thank you for all your help so far!
Upvotes: 2
Views: 2141
Reputation: 11728
Do you have IIS7? If so, it may be better to do this as a redirect there instead. It will also perform better as well as the request won't even come into your MVC application.
Edit: Someone else on WinHost posted this which may provide some help.
Upvotes: 2