url rewriting - Combination of IIS rewrite rules - redirect to changed domain name, remove hostname prefix redirect to ssl -


my iis website accessed http://mywebsite.com , have 3 objectives related url rewriting:

  1. redirect website's new name, mynewwebsite.com
  2. remove www prefix if exists (eg www.mywebsite.com -> mywebsite.com or www.mynewwebsite.com --> mynewwebsite.com
  3. redirect ssl

so in summary want redirect inbound requests https://mynewwebsite.com/anything*.

the input cases must accounted are

my rewrite rules follows:

<rewrite>   <rules>     <rule name="do stuff" enabled="true">       <match url="(.*)" ignorecase="false" />       <conditions logicalgrouping="matchany">         <add input="{https}" pattern="off" />         <add input="{http_host}" pattern="mywebsite.com" />         <add input="{https}" pattern="^www.mynewwebsite\.com$" />       </conditions>       <action type="redirect" url="https://mynewwebsite.com/{r:1}" appendquerystring="true" redirecttype="permanent" />     </rule>   </rules> </rewrite> 

with rule set following input case failing (the www isn't stripped): https://www.mynewwebsite.com/anything*

i've banged head against sufficiently question fundamental understanding of how rule definitions work.

  • anything present or not exist @ all

i arrived @ following rules work, afraid coincidence rather me understanding what's happening. comments welcome.

<rewrite>   <rules>     <rule name =" force https" enabled="true">       <match url =" (.*)" ignorecase= "false " />       <conditions logicalgrouping =" matchany" >         <add input =" {http_host}" negate="true" pattern =" ^mynewwebsite\.com$" />         <add input =" {https}" pattern= "^www.mynewwebsite\.com$ " />         </conditions>       <action type =" redirect" url= "https://mynewwebsite.fm/{r:1} " appendquerystring="true" redirecttype =" permanent" />     </rule>   </rules> </rewrite> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -