To add match url in rewrite rule using appcmd use below command:
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].match.url:"(client*)""
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /+"[name='Redirect to HTTPS'].conditions.[input='{REQUEST_FILENAME}',matchType='IsFile']"
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /+"[name='Redirect to HTTPS'].conditions.[input='{REQUEST_FILENAME}',matchType='IsDirectory']"
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].action.type:"Rewrite""
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].action.url:"client/index.html""
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
From your post, I can see that your issue in the original post is solved now. i request you to mark the helpful suggestion as an answer.
Thank you for understanding.
Regards,
Jalpa.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
15 Posts
How to add URL Rewrite using command line
Jan 15, 2019 02:56 AM|trongthai|LINK
I searched many places but nowhere is there a way to create a rewrite url using cmd.
Someone please help me.
964 Posts
Re: How to add URL Rewrite using command line
Jan 15, 2019 07:07 AM|Jalpa Panchal|LINK
Hi trongthai,
To add match url in rewrite rule using appcmd use below command:
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].match.url:"(client*)""
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /+"[name='Redirect to HTTPS'].conditions.[input='{REQUEST_FILENAME}',matchType='IsFile']"
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /+"[name='Redirect to HTTPS'].conditions.[input='{REQUEST_FILENAME}',matchType='IsDirectory']"
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].action.type:"Rewrite""
• appcmd.exe set config "site1" -section:system.webServer/rewrite/rules /"[name='Redirect to HTTPS'].action.url:"client/index.html""
output:
<rule name="Redirect to HTTPS">
<match url="(client*)" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" />
</conditions>
<action type="Rewrite" url="client/index.html" />
</rule>
You could also refer https://forums.iis.net/t/1240029.aspx post.
Regards,
Jalpa.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
15 Posts
Re: How to add URL Rewrite using command line
Jan 15, 2019 07:13 AM|trongthai|LINK
Thanks Jalpa Panchal,
That's exactly what I need.
Thank you so much.
964 Posts
Re: How to add URL Rewrite using command line
Jan 15, 2019 07:18 AM|Jalpa Panchal|LINK
Hi,
From your post, I can see that your issue in the original post is solved now. i request you to mark the helpful suggestion as an answer.
Thank you for understanding.
Regards,
Jalpa.
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
15 Posts
Re: How to add URL Rewrite using command line
Jan 15, 2019 09:52 AM|trongthai|LINK
In case I created a new website and didn't have a web.config file, what should I do?
8502 Posts
MVP
Re: How to add URL Rewrite using command line
Jan 16, 2019 06:03 PM|lextm|LINK
Run a script file at command line is enough, https://myadventuresincoding.wordpress.com/2015/02/06/iis-powershell-script-to-add-iis-url-rewrite-rule/
https://lextudio.com
---------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
15 Posts
Re: How to add URL Rewrite using command line
Jan 17, 2019 02:06 AM|trongthai|LINK
I tried this and got an error:
'Add-WebConfigurationProperty' is an internal command or external command,
It is not recognized as an operable program or batch file.
8502 Posts
MVP
Re: How to add URL Rewrite using command line
Jan 17, 2019 02:58 PM|lextm|LINK
I am not asking you to call "Add-WebConfigurationProperty" at command prompt, as that obviously won't work.
https://lextudio.com
---------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.