Link to home
Start Free TrialLog in
Avatar of taz8020
taz8020Flag for United Kingdom of Great Britain and Northern Ireland

asked on

asp.net rewrite Url to use subdomain to point to application Blog folder

Hi i have a application folder called /blogengine/
and all works fine, but want it to look like blog.mysite.co.uk

Tring to use this in web.config file but does not seem to make a diffecence, do i need to put it both root config and folder config (if not which one its in the root one at the moment)

     <rule name="blogDir" enabled="true">
          <match url="(.*)" />
          <conditions logicalGrouping="MatchAny">
            <add input="{HTTP_HOST}" pattern="^blog.mysite\.co\.uk$" />
          </conditions>
          <action type="Rewrite" url="\blogengine\{R:0}" />
        </rule>

Open in new window


Everyone seems to say about different ways to do this like take ot the / and use {R:1} so also tried this and lots of others but now joy just dont get how they work so dont know what I am doing wrong.

<rule name="Rewrite blog-domain to blogengine" enabled="true">
            <match url="(.*)$" />
            <conditions>
              <add input="{HTTP_HOST}" pattern="^blog.mysite.co.uk$" />
            </conditions>
            <action type="Rewrite" url="\blogengine\{R:1}" />
          </rule>

Open in new window


or

<rule name="Rewrite sub-domain to dir" enabled="true">
          <match url="^(.*)$" />
          <conditions>
             <add input="{HTTP_HOST}" pattern="^blog\.mysite\.co\.uk$" />
          </conditions>
          <action type="Rewrite" url="blogengine/{R:1}" />
       </rule>

Open in new window



Please tell me what I am doing wrong
ASKER CERTIFIED SOLUTION
Avatar of bepsoccer1
bepsoccer1
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of taz8020

ASKER

no still does not work, its like its not there i just get the normal home page on the root

but if i use
 <rule name="Rewrite sub-domain to dir" enabled="true">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="http://blog.mysite.co.uk$" />
          </conditions>
          <action type="Rewrite" url="http://www.mysite.co.uk/blogengine/{R:1}" />
        </rule>

I get the root home page without any images or css. Is there a setting i have to turn on first?
try adding appendQueryString="true", i.e. <action type="Rewrite" url="http://www.mysite.co.uk/blogengine/{R:1}" appendQueryString="true" />
Avatar of taz8020

ASKER

No still not working

but this sort of works

        <rule name="blog" stopProcessing="true">
          <match url="Blogengine/(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="www.mysite.co.uk" />
            <add input="{HTTP_HOST}" pattern="blog.mysite.co.uk" />
          </conditions>
          <action type="Redirect" url="http://blog.mysite.co.uk/{R:1}" />
        </rule>
        <rule name="BlogRewrite">
             <match url="blogengine/(.*)" negate="true" />
                     <conditions>
                         <add input="{HTTP_HOST}" pattern="www.mysite.co.uk" />
                     </conditions>
                     <action type="Rewrite" url="/blogengine/{R:1}" />
        </rule>

Open in new window

Avatar of taz8020

ASKER

had to do it a diiferent way