【发布时间】:2019-12-23 16:46:53
【问题描述】:
我正在尝试用 web.config 文件重写我的网址。
实际网址: sudomain.mydomain.com/legal.html
希望的网址: legal.mydomain.com
我已经隐藏了 html 扩展名。
<rule name="Hidehtml" enabled="true">
<match ignoreCase="true" url="Legal" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="Legal.html"/>
</rule>
我看到子文件夹可以进行这种重写,但我想知道文件是否可以。 我正在尝试这个,但它给了我一个 DNS 错误。
<rule name="testrule" stopProcessing="true">
<match url="legal(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="mydomain.com" />
</conditions>
<action type="Redirect" url="http://legal.mydomain.com" />
</rule>
我想知道我是否没有遗漏什么,也许也需要重定向?
感谢您的帮助!
【问题讨论】:
-
“希望的 URL”是什么意思?你希望浏览器地址栏最后显示什么?在说清楚之前,我建议你不要猜测重写或重定向。
标签: url iis url-rewriting web-config