« Previous Next »

Thread: Rewrite URL -> subfolder to subdomain

Last post 10-09-2009 10:57 AM by nikola tesla. 6 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (7 items)

Sort Posts:

  • 10-01-2009, 8:17 AM

    Rewrite URL -> subfolder to subdomain

    How can I rewrite url in client browser so that when client open this:

    http://www.domain.org/subfolder/default.aspx

    ... to be in client browser url box like this:

    http://www.subfolder.domain.org/default.aspx

     Is this possible and how?

    Thanx

  • 10-01-2009, 6:54 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 3:38 PM
    • Redmond, WA
    • Posts 664

    Re: Rewrite URL -> subfolder to subdomain

    I think you want to do a redirection: when client browser makes a request to one URL, it gets redirected to another one. you can use a rule like this for that:

    <rule name="Canonical Host Name" stopProcessing="true">
      <match url="^subfolder/(.*)" />
      <action type="Redirect" url="http://www.subfolder.domain.org/{R:1}" redirectType="Permanent" />
    </rule>

    For more information refer to the URL rewriter docs: http://learn.iis.net/page.aspx/460/using-url-rewrite-module/

    http://ruslany.net
  • 10-02-2009, 8:00 AM In reply to

    Re: Rewrite URL -> subfolder to subdomain

    Thanks a lot, but with that code I got a Redirect loop error.

    When I change to Rewrite, I got an error:

    HTTP Error 404.4 - Not Found

    The resource you are looking for does not have a handler associated with it.

    I'm on the shared hosting. They do not have Application Request Routing module installed.  Is that a problem maybe? They also do not have URL Rewrite Module v2.0. (they have v1.1 I think).

     

    On my hosting I have a subfolder which is configured as Virtual directory with Web Application in it. I also have a different Web Application in the root of the site.

    I make rule and associated rewrite map so that when user types www.subdomain.domain.org/blog and client browser opens the page www.domain.org/subdomainfolder/blog.aspx succesfuly, with url in client browser being the requested www.subdomain.domain.org/blog. Great so far. But, on post back on the same page which is induced by clicking a button, url in client browser convert to this www.subdomain.domain.org/subdomainfolder/blog.aspx.

     I need that WebApp in that subfolder performs next (I think it is rewrite):

    All that clinet browser url box would always should show to be in format
    ww.subdomainblog.domain.org/blog.aspx , meaning that everything that is in format of www.domain.org/blog... be in the client url browser text box like www.blog.domain.org/...

     In the root of the site I have Glogal.asax.cs, and in Application_BeginRequest I have redirect rules for subdomains. I guess this can be done through rules also. 

    What is the best way do that kind of redirect || rewrite?

    Is what I need in new features of URL Rewrite module v2.0? Outbound Rules?

    Many questions. Thanx

     

     



  • 10-06-2009, 1:59 AM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 3:38 PM
    • Redmond, WA
    • Posts 664

    Re: Rewrite URL -> subfolder to subdomain

    Outbound rules would help here, but if you do not have URL Rewrite 2.0 you could try overwriting the action property of the form by using an example described here: http://learn.iis.net/page.aspx/517/url-rewriting-for-aspnet-web-forms/#Form_postback_URL

    http://ruslany.net
  • 10-06-2009, 8:56 AM In reply to

    Re: Rewrite URL -> subfolder to subdomain

     Thank you, that helped a lot.

    I have  URL Rewrite 2.0 module in virtual machine so I can practice, and I need to automate url rewrite response.

    So for basic functinality of converting

    www.domian.org/subdomainfolder/default.aspx

    to this

    www.subdomainfolder.domain.org/default.aspx

    what I need to do, to automate url rewrite response in URL Rewrite module v2.0?

    Thanx

     

     

  • 10-07-2009, 4:34 PM In reply to

    • ruslany
    • Top 25 Contributor
    • Joined on 07-01-2007, 3:38 PM
    • Redmond, WA
    • Posts 664

    Re: Rewrite URL -> subfolder to subdomain

    This article explains how to create a rewrite rule to change the url links in the response: http://learn.iis.net/page.aspx/657/creating-outbound-rules-for-url-rewrite-module/

    http://ruslany.net
  • 10-09-2009, 10:57 AM In reply to

    Re: Rewrite URL -> subfolder to subdomain

     Thanx.

Page 1 of 1 (7 items)
Microsoft Communities