简体   繁体   English

如何使用IIS7 URL重写模块重定向到应用程序根目录?

[英]How to redirect to application root using the IIS7 URL Rewrite Module?

I have tried: 我努力了:

1) I tried empty string first: 1)我先尝试空字符串:

<action type="Redirect" url="" redirectType="Permanent" appendQueryString="false" />

Result: 结果:

HTTP 500.52 - URL Rewrite Module Error.
The substitution URL for the current action cannot be empty.

2) Maybe I should omit the url attribute: 2)也许我应该省略url属性:

<action type="Redirect" redirectType="Permanent" appendQueryString="false" />

Same result: 相同的结果:

HTTP 500.52 - URL Rewrite Module Error.
The substitution URL for the current action cannot be empty.

3) What about the ASP.NET way: 3)ASP.NET方式怎么样:

<action type="Redirect" url="~" redirectType="Permanent" appendQueryString="false" />

Tries to redirect to {APP_ROOT}/~ . 尝试重定向到{APP_ROOT}/~

4) Last try: 4)最后一次尝试:

<action type="Redirect" url="/" redirectType="Permanent" appendQueryString="false" />

As expected, it redirects to the root of the server... 正如所料,它重定向到服务器的根目录......

I'd like to find some clean generic solution. 我想找一些干净的通用解决方案。 (I cannot use some concrete /myCurrentAppPath .) (我不能使用一些具体的/myCurrentAppPath 。)

这效果更好:

<action type="Redirect" url="." redirectType="Permanent" appendQueryString="false" />

现在尝试这个,它不干净,但它的工作原理:

<action type="Redirect" url="?" redirectType="Permanent" appendQueryString="false" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM