从应用程序(在根域级别)重定向到子应用程序
问题描述:
我的主机只支持web.config IIS配置。我想重定向我从应用程序(在根域级别)重定向到子应用程序
http://domain - >http://domain/X
,这里是我的尝试
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="true" destination="http://domain/X/" />
</system.webServer>
</configuration>
它的工作原理,但它适用于所有网站的麻烦,当我已经在http://domain/X/它仍然工作,所以我越来越递归http://domain/X/X/X/X/X/X/X等等
临时解决方法是把
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<httpRedirect enabled="false" />
</system.webServer>
</configuration>
到http://domain/X和http://domain/Y等...但是当我去到http://domain/Y/Z它重定向反正我http://domain/X/Z/(所以地狱我真的不希望把这个任意文件夹中)
所以我想我需要修复第一次重定向(不知何故),使其仅适用于http://domain/
谢谢。
答
您可以尝试设置childOnly
属性 - 根据documentation,仅当文件名存在于url中时,才会重定向。所以只有表格http://domain/<file name>
的网址会被重定向到http://domain/X/<file name>
,这应该可以解决您的问题。要重定向http://domain/
,您可以使用重定向到http://domain/X
的默认文档。
你也可以看URL重写模块 - 见http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/(当然,它不会发出HTTP重定向,如果这是需要)
我加childOnly =“真”,但结果还是一样:HTTP :// domain/Y/Z它反正将我重定向到http:// domain/X/Z/- 这对我来说是错误的,我只想要域/重定向到domain/X并且能够与domain/Y一起工作。 – Cynede 2011-06-16 10:12:58