Hello, I have multiple domains.. they are all run with .net4 (mvc and web form) and use rewrite rule for them. for my web form application why my css url and form action url always point to my root folder path? for example. my domain folder path: root\domains\test1.abc.dom root\domains\test2.abc.com when I browse site test1.abc.com and view source.. the css point to folder path instead of the url? <link href="domains/test1.abc.com/Styles/Site.css" it should be <link href="/Styles/Site.css" and for the form action: <form method="post" action="domains/test1.abc.com/Account/Login.aspx" it should be <form method="post" action="Account/Login.aspx" Please advise.
and below are the rewrite rules.. <rule name="rule1" patternSyntax="Wildcard"> <match url="*" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="test1.abc.com" /> </conditions> <action type="Rewrite" url="domains/test1.abc.com/{R:0}?" /> </rule>
This is a pretty common issue when hosting multiple domains in the same site. You have a few options: Never use Request.ApplicationPath or "~/". This is acceptable for smaller sites. Redirect instead of rewrite. More on this on my blog Create rewrite rules for inbound and outbound. I'm doing this for my WordPress subdomain. See http://learn.iis.net/page.aspx/657/creating-outbound-rules-for-url-rewrite-module/ for more. Each option lends itself better for different types of web applications. You'll have to play around with your app and see what will work best for you situation.