?
Solved

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

Posted on 2013-05-20
5
Medium Priority
?
656 Views
Last Modified: 2013-07-05
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
0
Comment
Question by:taz8020
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Accepted Solution

by:
bepsoccer1 earned 1000 total points
ID: 39182219
Try this in the root.
<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

0
 
LVL 3

Author Comment

by:taz8020
ID: 39182682
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?
0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39182702
try adding appendQueryString="true", i.e. <action type="Rewrite" url="http://www.mysite.co.uk/blogengine/{R:1}" appendQueryString="true" />
0
 
LVL 3

Author Comment

by:taz8020
ID: 39192102
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

0
 
LVL 3

Author Closing Comment

by:taz8020
ID: 39301835
had to do it a diiferent way
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question