Redirect HTTP to HTTPS in Azure

We just installed SSL in our azure website to convert it to HTTPS.

Now we want that any request coming in as HTTP should be changed/redirected to HTTPS connection.

How can I do this?
ArikkanAsked:
Who is Participating?
 
Alex SmithConnect With a Mentor Hosting Solution ProviderCommented:
you can make it though below instruction.

http://blog.smarx.com/posts/redirecting-to-https-in-windows-azure-two-methods

Need more help please contact.
0
 
ArikkanAuthor Commented:
I tried this and it did not work on my server. So I used the simplest rule to test.
Even that did not work.

  </system.webServer>

        <rewrite>
            <rules>
                <rule name="Redirect to HTTPS">
                       <match url="*.*" />
                        <action type="Redirect" url="http://www.google.com"  />
                </rule>
            </rules>
        </rewrite>
  </system.webServer>

Open in new window


Any ideas?
0
 
ArikkanConnect With a Mentor Author Commented:
I ended up using this code:

  <system.webServer>
	<rewrite>
		<rules>		
			<rule name="HTTP to HTTPS redirect" stopProcessing="true">
				<match url="(.*)" />
					<conditions>
                        <add input="{HTTPS}" pattern="Off" />
						<add input="{REQUEST_METHOD}" pattern="^get$|^head$" />
					</conditions>
					<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
			</rule>			
		</rules>
	</rewrite>
  </system.webServer>

Open in new window



But now when the website is redirected from HTTP to HTTPS then,

if website was:

http://1.2.3.4/Website1/Pages/Page1.aspx

it switches to

https://1.2.3.4/Pages/Page1.aspx


"Website1" is missing !!!!!


Any ideas .........
0
 
ArikkanAuthor Commented:
I used this

<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="SeeOther" />
0
All Courses

From novice to tech pro — start learning today.