I have a site, that when people navigate to http://subdomain.mysite.com/ it is rewritten to
http://mysite.com/clientArea/Default.aspx?ID=1234
and then when people navigate to http://subdomain.mysite.com/AnythingElse.aspx it is then rewritten to http://mysite.com/clientArea/AnythingElse.aspx
The problem comes in with the stylesheets, for some reason they are resolving incorrectly.
In my code I have them entered like such
<link rel="Stylesheet" href="css/myStyleSheet.css" type="text/css" media="screen" />
But when I try to visit my website at http://subdomain.mysite.com/ and look at the source, they have changed to this
<link rel="Stylesheet" href="clientArea/css/myStyleSheet.css" type="text/css" media="screen" />
Which doesn't work because it's trying to get a resource from
http://subdomain.mysite.com/clientArea/css/myStyleSheet.css
where it should be trying to get the resources from
http://subdomain.mysite.com/css/myStyleSheet.css
I've tried a bunch of various fixes including adding in a Page.RequestUrl with the ~ and such, but they all add the clientArea in front. Which doesn't work since we're already in the clientArea folder.
Any help with this matter would be great.
Here are my rewrite rules
<rule name="Remove Subdomain" enabled="true" stopProcessing="true">
<match url="^$" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)subdomain\.mysite\.com$" />
</conditions>
<action type="Rewrite" url="clientArea/?ID=1234" appendQueryString="true" logRewrittenUrl="true" />
</rule>
<rule name="Everything Else" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www)subdomain\.mysite\.com$" />
</conditions>
<action type="Rewrite" url="clientArea/{R:0}" />
</rule>
Try to use URLRewriter.dll and apply below code in Global.ascx
if (Request.Url.AbsoluteUri.EndsWith(".jpg") || Request.Url.AbsoluteUri.EndsWith(".gif") ||
Request.Url.AbsoluteUri.EndsWith(".png") || Request.Url.AbsoluteUri.EndsWith(".ico") ||
Request.Url.AbsoluteUri.EndsWith(".js") || Request.Url.AbsoluteUri.EndsWith(".css"))
{ }
else
{
if (!Convert.ToString(arrPath[1]).Equals("admin", StringComparison.CurrentCultureIgnoreCase))
{
if (!Convert.ToString(arrPath[1]).Equals("demo.aspx", StringComparison.CurrentCultureIgnoreCase))
{
URLRewriter.Rewriter.Process();
}
}
}
And write rest of the Rule in web config and try it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.