简体   繁体   中英

IIS Redirect with appcmd causing recursive redirect

I'm trying to set a relative redirect using appcmd.exe with the following command:

appcmd.exe set config "Website" -section:system.webServer/httpRedirect /enabled:"True" /destination:"/Login/UnderConstruction.aspx" /httpResponseStatus:"Found"

"Website" has a binding of "http://localhost:81"

However this seems to be causing a recursive redirect, because when I visit localhost:81 , the following path is generated:

http://localhost:81/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/Login/UnderConstruction.aspx/

I have searched for this on google but I can't find anyone with the same issue. Is there a way to redirect all site requests to a path relative to that site without causing a recursive redirect?

I have resolved this using wildcards within the httpredirect

For example, the following script works:

appcmd.exe set config "Website" -section:system.webServer/httpRedirect /+"[wildcard='*.aspx',destination='/Login/UnderConstruction.aspx']" /destination:"" /enabled:"True" /exactDestination:"False" /childOnly:"False"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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