我目前正在使用iis进行网址重定向。
我需要完成以下任务:
我设法做第一件事,但不能做第二件事。我尝试了几种方法,但无法做到。:/
第一点的代码:
<rules>
<rule name="in a subfolder" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Redirect" url="http://www.domain.de/subdir" />
</rule>
</rules>
那么,有没有摆脱URL中的子目录的方法呢?
背景是:我的网站位于wwwroot的子目录中,但是我不希望公共URL中包含此信息,因此我需要将其重定向到正确的子目录,但是传出的URL必须忽略该子目录。
尝试:
<rule name="in a subfolder" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
</conditions>
<action type="Rewrite" url="/subdir/{R:0}" />
</rule>
我将动作更改为,Rewrite
并{R:0}
在输出中添加了的匹配标记,以将它们发送到中的正则表达式内的匹配网址subdir
。
例如:
http://www.domain.de/default.htm
这将呈现:
http://www.domain.de/subdir/default.htm
但仍显示http://www.domain.de/default.htm
在浏览器中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句