Skip to main content

How we Redirect website from HTTP to HTTPS from VPS/DS

In order to set the redirection on your website from your VPS/DS follow the below mentioned steps.

  1. Login on your VPS/DS using your RDP login details.

2. Once logged in go to your VPS/DS Hostingspaces that is mostly located in your VPS in “C” drive or in your DS it can be in the “D” drive” with the name of HostingSpaces.

3. Once you click on the “HostingSpaces” folder it will list your all users that are created click on the username under which your website is created or search your website name in the Search bar.

4. Once you have found your website open its document root that is the “wwwroot” and here you will find the “web.config” file under which you have to set the redirection rule.

5. Once you find the “web.config” file right click on it and click on the edit option and open in the wordpad or notepad and set the below redirection codes in this with the help of your developer team.

Kindly Note: Take the backup of your “web.config” fiel before making any changes.

1. 
<rule name="RedirectToHTTPS" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTPS}" pattern="off" ignoreCase="true" />
  </conditions>
  <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
</rule>



2. For redirecting requests from www to non-www ( i.e. https://example.com ):
<rule name="RedirectWwwToNonWww" stopProcessing="false">
  <match url="(.*)" />
  <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
  </conditions>
  <action type="Redirect" url="https://{C:2}{REQUEST_URI}" redirectType="Permanent" />
</rule>


3. For redirecting requests from non-www to www ( i.e. https://www.example.com ):
<rule name="RedirectNonWwwToWww" stopProcessing="true">
  <match url="(.*)" />
  <conditions>
    <add input="{HTTP_HOST}" pattern="^domain.com$" />
  </conditions>
  <action type="Redirect" url="http://www.domain.com/{R:0}" redirectType="Permanent" />
</rule>

Leave a Reply