subdomain with rewriteModule [Answered]RSS

10 replies

Last post Jul 31, 2009 01:15 PM by ruslany

  • subdomain with rewriteModule

    Jul 04, 2009 03:47 PM|sadegh-shad|LINK

     hi i'm using this rule for rewriting subdomain

    <rule name="SubDomain" stopProcessing="true">
        <match url="(.*)" />
        <conditions logicalGrouping="MatchAll">
            <add input="{HTTP_HOST}" pattern="^(.+).domain.com(.*)" />
        </conditions>
        <action type="Rewrite" url="{C:1}/{R:1}" />
    </rule><div class="post-text">

     

    and i'm corrected host file to

    127.0.0.1 domain.com

    when user typed news.domain.com/default.aspx it must return domain.com/news/default.aspx but browser showed Address not found.

    how do i?

    please help

    thanks all

    </div>

    RewriteModule

  • Re: subdomain with rewriteModule

    Jul 08, 2009 12:17 AM|ruslany|LINK

    I think you also need to add

    127.0.0.1 news.domain.com

    to your hosts file.

  • Re: subdomain with rewriteModule

    Jul 10, 2009 04:08 PM|sadegh-shad|LINK

    For each subdomain so I added this line do? you do not know another solution?

    Second question: When I use the subdomain, styles, images and JavaScript files are not affected. What should I do?
  • Re: subdomain with rewriteModule

    Jul 17, 2009 02:59 AM|sadegh-shad|LINK


  • Re: subdomain with rewriteModule

    Jul 17, 2009 02:59 AM|sadegh-shad|LINK

     I used his rule as the rewrite subdomain

     

    <rule name="Rewrite subdomain" stopProcessing="false">
     <match url="(.*)" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.domain\.net$" />
     </conditions>
     <action type="Rewrite" url="{C:1}/{R:1}" />
    </rule>

     

      I used his rule as the redirect subdomain

     

     <rule name="Redirect subdomain" stopProcessing="true">
     <match url="(\w+)/(.*)" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^domain\.net$" />
     </conditions>
     <action type="Redirect" url="http://{R:1}.domain.net/{R:2}"redirectType="Permanent" />
    </rule>

     When url have'nt www, Redirect subdomain work fine

    http://domain.net/news => http://news.domain.net

    but if url have www, Redirect subdomain does not working

    http://www.domain.net/news => http://www.domain.net/news

     

    What should I do?

    I apologize from the long post, thanks

     

  • Re: subdomain with rewriteModule

    Jul 17, 2009 11:05 PM|ruslany|LINK

    If you need http://www.domain.net/news to be redirected to http://news.domain.net :

     <rule name="Redirect subdomain" stopProcessing="true">
     <match url="(\w+)/(.*)" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="(?:www\.)?domain\.com" />
     </conditions>
     <action type="Redirect" url="http://{R:1}.domain.net/{R:2}"redirectType="Permanent" />
    </rule>

  • Re: subdomain with rewriteModule

    Jul 18, 2009 03:33 AM|sadegh-shad|LINK

    ruslan thank you because answer questions but

    But with this rule browser shows the message Redirect loop

    please answer this post too.

  • Re: subdomain with rewriteModule

    Jul 20, 2009 12:57 PM|ruslany|LINK

    This rule alone will not cause redirect loop. Most probably you have some other rule that causes a loop when combined with this rule. Please post the entire content of the <rewrite> section that you have.

  • Re: subdomain with rewriteModule

    Jul 20, 2009 04:32 PM|sadegh-shad|LINK

    thanks, that resolved. Whether do not you answer my question? When I use the subdomain, styles, images and JavaScript files are not affected and UpdatePanel dont work, What should I do?
  • Re: subdomain with rewriteModule

    Jul 30, 2009 02:50 AM|sadegh-shad|LINK

     oooooooops!

    Another problem I have with sub domain.

    I use from the following rules for redirecting and rewriting subdomain. when user request http://www.domain.com/news/, this request redirect to http://news.domain.com. and if user again request http://news.domain.com/90/sample for reading news details this redirect to http://90.domain.com/sample and each next request cause this problem. how can i resolve this problem?

     

    thanks in advance

    <rule name="Redirect subdomain" stopProcessing="true">
     <match url="(\w+)/(.*)" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="(?:www\.)?domain\.com$" />
     </conditions>
     <action type="Redirect" url="http://{R:1}.domain.com/{R:2}" redirectType="Permanent" />
    </rule>


    <rule name="Rewrite subdomain" stopProcessing="false">
     <match url="(.*)" />
     <conditions>
      <add input="{HTTP_HOST}" pattern="^(?!www)(\w+)\.domain\.com$" />
     </conditions>
     <action type="Rewrite" url="{C:1}/{R:1}" />
    </rule>

  • Re: subdomain with rewriteModule

    Jul 31, 2009 01:15 PM|ruslany|LINK

    Try modifying the condition in the redirect rule:

    <add input="{HTTP_HOST}" pattern="^(?:www\.)?domain\.com$" />