Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UrlRewrite via appcmd

I want to create urlrewrite url using appcmd for redirecting all requests from

http://

to

https://

I tried to google but nothing found. Could you provide me some basic example?

like image 759
user2598794 Avatar asked Oct 18 '25 14:10

user2598794


1 Answers

Got it working with this:

appcmd.exe set config -section:system.webServer/rewrite/rules /+"[name='http_redirect',enabled='True']" /commit:apphost

appcmd.exe set config -section:system.webServer/rewrite/rules.[name='http_redirect'] /match.url:"(.*)" /match.ignoreCase:true /commit:apphost

appcmd.exe set config -section:system.webServer/rewrite/rules.[name='http_redirect'].conditions/add /+"[input='{HTTPS}',pattern='off']" /commit:apphost

appcmd.exe set config -section:system.webServer/rewrite/rules.[name='http_redirect'].action /+"[type='Redirect',url='https://{HOST_NAME}/{R:1}',redirectType='Found']" /commit:apphost

This link can help on building appcmd scripts.

like image 155
user2598794 Avatar answered Oct 20 '25 07:10

user2598794



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!