In Linux & cPanel
Using .htaccess fileAdd the below code in the .htaccess file under the document route of the domain.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Replace www.example.com with the name of the domain which you want to re-direct.
Note: If you have an existing .htaccess file:
- Do not duplicate RewriteEngine On.
- Make sure the lines beginning RewriteCond and RewriteRule immediately follow the already-existing RewriteEngine On.
From cPanel
- log into your cPanel and access the redirects section (Home >> Domains >> Redirects)
- Set Type to Permanent (301)
- Next to http://(www.)? choose the domain name you are working with
- Next to redirects to, enter your website's url using the Shared SSL Certificate
- We recommend having Redirect with or without www. selected, so that the user will be forced to use SSL whether they use domain.com or www.domain.com
- Ensure Wild Card Redirect is selected
- Click Add
When you save this redirect, cPanel actually sets up the redirect by editing your .htaccess file.
Windows & Plesk
Windows-based accounts use web.config files to handle redirection.
Using the following code in your web.config file automatically redirects visitors to the HTTPS version of your site:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
You're inserting the rule (without an 's') inside the rules (with an 's') section.
Post A Comment:
0 comments: