regex - Force Https on an ASP.NET app running on IIS 7.5 -
i forcing ssl on entire site following code on web.config file;
<system.webserver> <rewrite> <rules> <rule name="redirect http https" stopprocessing="true"> <match url="(.*)"/> <conditions> <add input="{https}" pattern="^off$"/> </conditions> <action type="redirect" url="https://{http_host}/{r:1}" redirecttype="seeother"/> </rule> </rules> </rewrite> </system.webserver>
but force ssl ~/purchase/
, ~/account/
path , under them. should match url that?
note regular expressions work me here wildcard.
you should use pattern (this work /purchase/something
/account/something-else
):
^((purchase|account)/.*)$
you have remember, url should have no leading slash /
.
<?xml version="1.0" encoding="utf-8"?> <configuration> <system.webserver> <rewrite> <rules> <rule name="force https" stopprocessing="true"> <match url="^((purchase|account)/.*)$" /> <conditions> <add input="{https}" pattern="^off$" /> </conditions> <action type="redirect" url="https://{http_host}/{r:1}" redirecttype="permanent" /> </rule> </rules> </rewrite> </system.webserver> </configuration>
Comments
Post a Comment