Wednesday, March 17, 2021

 

How to export URL rewrite rules.


Wehave 2 options to export the rewrite rules:


1) We can look in the web.config file, and copy the <rewrite> section, then paste into the web.config file on the new system.

Or,

2) We can use appcmd to export the rules to a file, and to import them on the new system:


App command location: cd %windir%\system32\inetsrv


Export:

appcmd list config "websitename/appname" -section:system.webServer/rewrite/rules -xml > rewriterules.xml


Import (globaly on the server):

appcmd set config -in < rewriterules.xml

Import for a specific website:

 appcmd set config "testWebsite\" -in < rewriterules.xml

You can also export any global rewrite rules using:

appcmd list config -section:system.webServer/rewrite/globalRules -xml > globalrewriterules.xml

The import command would be the same.

No comments:

Post a Comment