{"id":248,"date":"2021-03-21T15:50:03","date_gmt":"2021-03-21T15:50:03","guid":{"rendered":"https:\/\/wshop.fi\/eng\/?p=248"},"modified":"2021-03-21T16:23:10","modified_gmt":"2021-03-21T16:23:10","slug":"iis-url-rewrite-installation-and-use-web-config","status":"publish","type":"post","link":"https:\/\/wshop.fi\/eng\/iis-url-rewrite-installation-and-use-web-config\/","title":{"rendered":"IIS URL Rewrite Tutorial &#8211; Installation and Use &#8211; web.config"},"content":{"rendered":"\n<p>To get the below URL Rewrite code to work in IIS, you must first install the URL Rewrite module. The URL Rewrite module is not installed by default. The IIS URL Rewrite module may be a better solution than HTTP Redirect in IIS. You can effectively&nbsp;<strong>\u201credirect\u201d from http:\/\/domain.com to http:\/\/www.domain.com<\/strong>. Of course the URL rewrite has many more uses and features, but we will use it for redirection purposes in this tutorial.<\/p>\n\n\n\n<p>To install the IIS URL Rewrite module:\u00a0<a rel=\"noreferrer noopener\" href=\"http:\/\/www.iis.net\/download\/URLRewrite\" target=\"_blank\">Go Here<\/a>\u00a0and click install\u2026 Or just click\u00a0<a href=\"http:\/\/www.microsoft.com\/web\/handlers\/webpi.ashx?command=getinstaller&amp;appid=urlrewrite2\">here<\/a>. Once installed you may need to reboot.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"508\" src=\"https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/install-iis-url-rewrite-module-2.png\" alt=\"\" class=\"wp-image-252\" srcset=\"https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/install-iis-url-rewrite-module-2.png 728w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/install-iis-url-rewrite-module-2-300x209.png 300w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/install-iis-url-rewrite-module-2-696x486.png 696w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/install-iis-url-rewrite-module-2-602x420.png 602w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/install-iis-url-rewrite-module-2-100x70.png 100w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">IIS URL Rewrite after Installation<\/h2>\n\n\n\n<p>You can double click and make your URL rewrite rule using the interface, or edit the web.config. See below.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"278\" src=\"https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/iis-url-rewrite-module.png\" alt=\"\" class=\"wp-image-255\" srcset=\"https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/iis-url-rewrite-module.png 728w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/iis-url-rewrite-module-300x115.png 300w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/iis-url-rewrite-module-696x266.png 696w\" sizes=\"auto, (max-width: 728px) 100vw, 728px\" \/><figcaption>IIS URL Rewrite Module<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">IIS URL Rewrite code in the web.config<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!--web.config url rewrite-->\n  &lt;system.webServer>\n      &lt;rewrite>\n          &lt;rules>\n              &lt;rule name=\"RedirectToWWW\" stopProcessing=\"true\">\n                  &lt;match url=\".*\" ignoreCase=\"true\" \/>\n                  &lt;conditions>\n                      &lt;add input=\"{HTTP_HOST}\" pattern=\"^domain.com$\" \/>\n                  &lt;\/conditions>\n                  &lt;action type=\"Redirect\" url=\"http:\/\/www.domain.com\/{R:0}\" redirectType=\"Permanent\" \/>\n              &lt;\/rule>\n          &lt;\/rules>\n      &lt;\/rewrite>\n  &lt;\/system.webServer><\/code><\/pre>\n\n\n\n<p>Previous to IIS7 this was handled in:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;system.web>\n&lt;\/system.web><\/code><\/pre>\n\n\n\n<p>The above code can be viewed in the URL rewrite module interface. It\u2019s illustrated below. You may add or modify in either the web.config, or this interface. The main thing is to get it installed, and most likely reboot.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">URL Rewrite Rules Interface in IIS<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"615\" height=\"866\" src=\"https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/url-rewrite-module-edit-in-iis.png\" alt=\"\" class=\"wp-image-256\" srcset=\"https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/url-rewrite-module-edit-in-iis.png 615w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/url-rewrite-module-edit-in-iis-213x300.png 213w, https:\/\/wshop.fi\/eng\/wp-content\/uploads\/2021\/03\/url-rewrite-module-edit-in-iis-298x420.png 298w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><figcaption>URL Rewrite Interface in IIS<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">IIS 7 redirect using URL Rewrite<\/h2>\n\n\n\n<p>Notice under the \u201cAction\u201d section in the above image there is a selection for&nbsp;<strong>\u201cAction type\u201d<\/strong>. Among other choices you can choose Redirect. Choose&nbsp;<strong>\u201cRedirect.\u201d<\/strong>&nbsp;Once selected there are then places for you to select&nbsp;<strong>\u201cRedirect URL,\u201d<\/strong>&nbsp;and&nbsp;<strong>\u201cRedirect type,\u201d<\/strong>&nbsp;such as&nbsp;<strong>\u201cPermanent (301).\u201d<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get the below URL Rewrite code to work in IIS, you must first install the URL Rewrite module. The URL Rewrite module is not installed by default. The IIS URL Rewrite module may be a better solution than HTTP Redirect in IIS. You can effectively&nbsp;\u201credirect\u201d from http:\/\/domain.com to http:\/\/www.domain.com. Of course the URL rewrite [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":192,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":{"0":"post-248","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-coding"},"_links":{"self":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts\/248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/comments?post=248"}],"version-history":[{"count":2,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts\/248\/revisions"}],"predecessor-version":[{"id":257,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/posts\/248\/revisions\/257"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/media\/192"}],"wp:attachment":[{"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/media?parent=248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/categories?post=248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wshop.fi\/eng\/wp-json\/wp\/v2\/tags?post=248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}