In IIS rewrite rules, is it possible to return a CustomResponse statusCode with a URL?

泄露秘密 提交于 2021-01-27 21:50:08

问题


We are planning a maintenance window for some of our sites (say at a.b.com, b.b.com and c.b.com). What we would like to do is to return a 503 return code for a holding page sitting on our main site (which is powered by a Tridion CMS database) (say at www.b.com/maintenance.html) as that site is not undergoing maintenance. Is that possible?

We know you can create an app_offline.htm file in the root of each of the applications undergoing maintenance, but that would require us to build a maintenance page for each application, rather than just to add some content to a page on our main site and publish that content out through our CMS. A redirect could then be created in our load balancer for the domains undergoing maintenance to the holding page.


回答1:


Yes. You can create a CustomResponse action type. Here is the documentation for creating custom response codes: https://technet.microsoft.com/en-us/library/ee215207(v=ws.10).aspx

<rule name="My custom response">
    <match url="^my_url_regex_pattern$"/>
    <action type="CustomResponse" statusCode="503" statusReason="Undergoing Maintenance" />
</rule>


来源:https://stackoverflow.com/questions/42114236/in-iis-rewrite-rules-is-it-possible-to-return-a-customresponse-statuscode-with

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!