Answered by:
subdomain with rewriteModule

Question
-
User908366564 posted
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>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
Saturday, July 4, 2009 3:47 PM
Answers
-
User-1637866776 posted
Try modifying the condition in the redirect rule:
<add input="{HTTP_HOST}" pattern="^(?:www\.)?domain\.com$" />
- Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
Friday, July 31, 2009 1:15 PM
All replies
-
User-1637866776 posted
I think you also need to add
127.0.0.1 news.domain.com
to your hosts file.
Wednesday, July 8, 2009 12:17 AM -
User908366564 posted
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?Friday, July 10, 2009 4:08 PM -
User908366564 posted
Friday, July 17, 2009 2:59 AM -
User908366564 posted
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.netbut 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
Friday, July 17, 2009 2:59 AM -
User-1637866776 posted
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>Friday, July 17, 2009 11:05 PM -
User908366564 posted
ruslan thank you because answer questions but
But with this rule browser shows the message Redirect loop
please answer this post too.
Saturday, July 18, 2009 3:33 AM -
User-1637866776 posted
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.
Monday, July 20, 2009 12:57 PM -
User908366564 posted
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?Monday, July 20, 2009 4:32 PM -
User908366564 posted
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>
Thursday, July 30, 2009 2:50 AM -
User-1637866776 posted
Try modifying the condition in the redirect rule:
<add input="{HTTP_HOST}" pattern="^(?:www\.)?domain\.com$" />
- Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
Friday, July 31, 2009 1:15 PM