How to

How to redirect http to https in IIS

Ravindra Kumar

o redirect HTTP to HTTPS in IIS (Internet Information Services), you have a few options depending on your setup. Here’s how to do it step-by-step:

Method 1: Using IIS HTTP Redirect Module

This works best for simple websites and requires the HTTP Redirect feature to be installed.

Steps:

  1. Open IIS Manager.

  2. Select your website from the Connections pane.

  3. Double-click on HTTP Redirect in the Features View.

  4. Check “Only redirect requests to content in this directory (not subdirectories)”.

  5. Enter your HTTPS URL, e.g., https://www.example.com.

  6. Check “Only respond to requests to this site”.

  7. Click Apply on the right pane.

  8. In the Actions pane, click Apply to save the changes.

Method 2: Using Web.config File

This is preferred if you want to maintain the redirects in a deployable file.

Add this to your web.config inside <system.webServer>:


<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Make sure the URL Rewrite module is installed in IIS for this to work.

Method 3: Use IIS GUI (URL Rewrite Module)

  1. Open IIS Manager.

  2. Select your site.

  3. Double-click URL Rewrite.

  4. Click “Add Rules…” in the right Actions panel.

  5. Select “Blank Rule” under Inbound Rules, then click OK.

  6. Name it something like Redirect to HTTPS.

  7. Under Conditions, click Add:

    • Condition input: {HTTPS}

    • Check if input string: Matches the Pattern

    • Pattern: off

  8. Under Action:

    • Action type: Redirect

    • Redirect URL: https://{HTTP_HOST}/{R:1}

    • Redirect type: Permanent (301)

  9. Click Apply to save.

Here’s a ready-to-use web.config file that redirects all HTTP requests to HTTPS using the URL Rewrite module in IIS.

This works only if the URL Rewrite module is installed on your server.

Sample web.config File:


<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect to HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Instructions:

  1. Open or create a web.config file in your site’s root folder.

  2. Paste the above XML code.

  3. Save the file.

  4. Make sure the URL Rewrite module is installed on your IIS server.

How to Check if URL Rewrite Module is Installed:

  1. Open IIS Manager.

  2. Select your website.

  3. In the Features View, look for URL Rewrite.

How to redirect http to https in htacccess file

How to redirect non-www to www in htaccess file

Ravindra Kumar

Ravindra is a passionate full stack developer and dedicated blogger with a flair for crafting user-friendly web applications and insightful articles. With expertise spanning front-end and back-end technologies, Ravindra brings ideas to life through innovative coding solutions.

Suggested Reading

Call to undefined method Intervention\Image\ImageManager::make() in Laravel

The error “Call to undefined method Intervention\Image\ImageManager::make()” typically happens when you’re trying to use the make() method from the Intervention Image package but haven’t correctly set up the manager or are using the wrong instance. Solution Make sure you’re using Intervention\Image\Facades\Image facade, not ImageManager directly. 1. Correct Usage in Laravel In your controller or wherever […]

How to redirect non-www to www in htaccess file

To redirect non-www to www using your .htaccess file, add the following code: RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Combined with HTTP to HTTPS redirect If you also want to force HTTPS and redirect non-www to www, here’s a combined version: </p> RewriteEngine On # Force HTTPS RewriteCond %{HTTPS} off RewriteRule ^(.*)$ […]

How to redirect http to https in htacccess file

To redirect all HTTP traffic to HTTPS using .htaccess, you can use the following code snippet: RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Steps: Locate the .htaccess file in the root directory of your website (often public_html/). If there is no .htaccess file, create one. Paste the above code at the top of […]

Whatsapp Contact Form Source Code Html CSS Javascript

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Contact Form</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <style> body { background-color: #f8f9fa; } .contact-form { max-width: 600px; margin: 50px auto; padding: 20px; background: #fff; border-radius: 10px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); } </style> </head> <body> <div class="container"> <div class="contact-form"> <h2 class="text-center mb-4">Contact Us</h2> […]

Making WhatsApp Order Form using HTML, CSS, Javascript

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Order Form</title> <!-- Bootstrap CSS --> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> <script> function sendOrderToWhatsApp() { // Retrieve form values var name = document.getElementById('name').value; var email = document.getElementById('email').value; var contact = document.getElementById('contact').value; var address = document.getElementById('address').value; var pincode = document.getElementById('pincode').value; var landmark = document.getElementById('landmark').value; // Retrieve product selections var […]

How to submit HTML Form to WhatsApp | Sending Form fields to WhatsApp Using HTML,CSS and Javascript

Whatsapp Form Code Generator Tool In this post I am going to explain how can we submit HTML form to WhatsApp. By using this functionality form’s data will be summited to chat interface of WhatsApp, As normally we chat on WhatsApp. This example will tell you about sending form fields to WhatsApp by using JavaScript. […]