我的网站是html,所有文件现在放在httpdocs目录中,我的网址就像。
http://Mysite.com/httpdocs/test.html and i need to show
http://Mysite.com/test.html
在我的谷歌自定义搜索中。 我在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的限制所以请让我知道一些最好的建议或如果我可以在一行中写一些规则然后它将没事。
答案 0 :(得分:0)
如果您在IIS 7.5上托管应用程序并且可以安装URL Rewrite module:
,则可以轻松完成此操作 <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>