Question

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?

Was it helpful?

Solution

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"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top