{"id":10068,"date":"2020-06-26T10:43:45","date_gmt":"2020-06-26T10:43:45","guid":{"rendered":"https:\/\/v9.tarikatechnologies.com\/knowledge-base\/uncategorized\/how-to-redirect-http-in-https-on-iis7-using-url-rewrite-2-0\/"},"modified":"2023-03-29T07:41:44","modified_gmt":"2023-03-29T07:41:44","slug":"how-to-redirect-http-in-https-on-iis7-using-url-rewrite-2-0","status":"publish","type":"knowledgebase","link":"https:\/\/v9.tarikatechnologies.com\/knowledge-base\/miscellaneous\/how-to-redirect-http-in-https-on-iis7-using-url-rewrite-2-0\/","title":{"rendered":"Automatically Redirect HTTP requests to HTTPS on IIS 7 using URL Rewrite 2.0"},"content":{"rendered":"
URL Rewrite has a GUI to allow you to enter rules within IIS 7; in the background all this does is edit the web.config file of the site.
\nI will show you how to create a rule both ways.<\/p>\n
In the following example we will redirect HTTP to HTTPs using URL Rewrite. You will need the following items completed in order for this to work correctly.<\/p>\n
You will notice there are currently no rules configured for this site. Click \u201cAdd Rules\u2026\u201d in the Actions menu to the right of the \u201cFeatures View\u201d panel
\n<\/p>\n
Use the default \u201cBlank rule\u201d and press \u201cOK\u201d.
\n<\/p>\n
When editing a rule there are the \u201cName\u201d field and 4 configuration pull down boxes.<\/p>\n
Within the \u201cMatch URL\u201d configuration box we will set the following settings:<\/strong> We can now edit the next configuration pull down box which is \u201cConditions\u201d, Press \u201cAdd\u2026\u201d to add a new condition to the configuration. We will configure the condition with the following settings:<\/strong> Press \u201cOK\u201d You should see your condition in the list of conditions. For this setting we do not need to configure the \u201cServer Variables\u201d pull down box. Continue onto the \u201cAction\u201d configuration box and pull down the box by selecting the arrow on the right. Action Type:<\/strong> Redirect Press \u201cApply\u201d then press \u201cBack to Rules\u201d You should now see the rule configured on the main screen of the URL Rewrite module. Test your site, it should now redirect from HTTP to HTTPS.<\/p>\n If we exam the web.config file we can see where the rule was entered. If we entered the rule directly into the web.config file it would show up in the GUI. Web.Config Rule<\/strong> When implementing this solution you need to make sure to use relative paths for all references on your page because there is a possibility you will get a warning asking you if you want to display secure and insecure items. For example, if you have a logo on your page and the URL to this logo is http:\/\/domain\/images\/logo.jpg, do not use the whole path because including the http:\/\/ will hard code this image to use http and not https. Instead use \/images\/logo.jpg.<\/p>\n","protected":false},"excerpt":{"rendered":" URL Rewrite has a GUI to allow you to enter rules within IIS 7; in the background all this does is edit the web.config file of the site. I will show you how to create a rule both ways. In the following example we will redirect HTTP to HTTPs using URL Rewrite. You will need …<\/p>\n
\nRequested URL:<\/strong> Matches the Pattern
\nUsing:<\/strong> Regular Expressions
\nPattern:<\/strong> (.*)
\n<\/p>\n
\n<\/p>\n
\nCondition Input:<\/strong> {HTTPS}
\nCheck if input string:<\/strong> Matches the Pattern
\nPattern<\/strong>: ^OFF$<\/p>\n
\n<\/p>\n
\n<\/p>\n
\nWe will configure the following settings for the \u201cAction\u201d configuration:<\/strong><\/p>\n
\nRedirect URL:<\/strong> https:\/\/{HTTP_HOST}\/{R:1}
\nRedirect Type:<\/strong> See Other (303)
\n<\/p>\n
\n<\/p>\n
\n<\/p>\n
\n<\/p>\n
\nYou can also edit the web.config file of the site directly and you will be able to see the rule in the GUI. You will need to enter the following within the elements.
\n<\/p>\n