2

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!

lookitskris
  • 678
  • 1
  • 6
  • 23
  • Check out this post: https://stackoverflow.com/questions/278668/is-it-possible-to-make-an-asp-net-mvc-route-based-on-a-subdomain/541495#541495 – hunter Dec 28 '10 at 18:58

1 Answers1

2

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.

Dan Atkinson
  • 11,391
  • 14
  • 81
  • 114
  • I'm afraid that I can't tell what the rule is doing unless I can see the XML that is created (I'm strange that way!). I don't suppose you can provide me with that (with your domain suitably altered). – Dan Atkinson Dec 28 '10 at 21:05
  • Much obliged! Try the match pattern as `blog.mysite.com/(.*)` and then redirect to `mysite.com/blog/{R:1}`. Not completely sure the match conditions are required either. I tend not to use them on my sites. – Dan Atkinson Dec 28 '10 at 21:30
  • still just defaulting to "www.mysite.com"..this has given me a few more ideas though so I will keep trying...thank you very much for your help! – lookitskris Dec 28 '10 at 22:39