How to redirect to application root using IIS7 URL rewrite module?

I tried:

1) First I tried an empty line:

<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:

 <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 path:

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

Trying to redirect to {APP_ROOT}/~ .

4) Last attempt:

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

As expected, it redirects to the server root ...

I would like to find some kind of clean general solution. (I cannot use the specific /myCurrentAppPath .)

+7
web-applications url-rewriting iis iis-7 url-rewrite-module
source share
2 answers

This works better:

 <action type="Redirect" url="." redirectType="Permanent" appendQueryString="false" /> 
+5
source share

Try for now, it will not clear, but it works:

 <action type="Redirect" url="?" redirectType="Permanent" appendQueryString="false" /> 
+2
source share

All Articles