7

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

1)我第一次尝试空字符串:

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

结果:

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

2)也许我应该省略url属性:

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

相同结果:

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

3)怎么样的ASP.NET方式:

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

设法重新指向{APP_ROOT}/~

4)最后一次尝试:

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

正如预期的那样,它重定向到服务器的根......

我想找到一些干净的通用的解决方案。 (我不能用一些具体/myCurrentAppPath

回答

5

这工作得更好:

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

+1好吧。谢谢。 – 2010-05-11 12:36:57

2

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

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

谢谢!让我知道如果你找到更好的解决方案:) – 2010-03-11 11:11:37