[英]web.config rule for 301 redirection
我的網站是html,現在所有文件都放在httpdocs目錄中,我的網址像一樣。
http://Mysite.com/httpdocs/test.html and i need to show
http://Mysite.com/test.html
在我的Google自定義搜索中。 我已經在web.config中使用了301重定向,就像
<location path="httpdocs/test.html">
<system.webServer>
<httpRedirect enabled="true" destination="/test.html " exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>
和它的工作約750個網址,但我有1500個網址,我認為這超出了web.config的限制,所以請讓我知道一些最佳建議,或者如果我可以為它寫一些規則,那就很好了。
如果您將應用程序托管在IIS 7.5上並且可以安裝URL重寫模塊,則可以輕松完成此操作:
<system.webServer>
<rewrite>
<rule name="Stop" stopProcessing="true">
<match url="^httpdocs/" />
<action type="AbortRequest"/>
</rule>
<rule name="Rewrite">
<match url=".*" />
<action type="Rewrite" url="httpdocs/{R:0}" />
</rule>
</rewrite>
</system.webServer>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.