相对路径不适用于 IIS 重写
我有一个网站,当人们导航到 http://subdomain.mysite.com/ 时,它会被重写为
http://mysite.com/clientArea/Default.aspx?ID=1234
进而当人们导航到 http://subdomain.mysite.com/AnythingElse.aspx 时,它会被重写到 http://mysite.com/clientArea/AnythingElse.aspx
问题与样式表一起出现,由于某种原因它们解析不正确。
在我的代码中,我像这样输入了它们
<link rel="Stylesheet" href="css/myStyleSheet.css" type="text/css" media="screen" />
但是当我尝试访问我的网站时 http://subdomain.mysite.com/ 并查看源代码,它们已更改为这
<link rel="Stylesheet" href="clientArea/css/myStyleSheet.css" type="text/css" media="screen" />
不起作用,因为它试图从
http://subdomain.mysite.com/clientArea/css/myStyleSheet.css
应该尝试从
http://subdomain.mysite.com/css/myStyleSheet.css
我已经尝试了一系列各种修复,包括添加 Page.RequestUrl 与〜和这样,但是他们都在前面添加了clientArea。这是行不通的,因为我们已经位于 clientArea 文件夹中。
任何有关此事的帮助都会很棒。
这是我的重写规则
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用 URLRewriter.dll 并在 Global.ascx 中应用以下代码
,并在 Web 配置中编写规则的其余部分并尝试。
Try to use URLRewriter.dll and apply below code in Global.ascx
And write rest of the Rule in web config and try it.