How to redirect site from http to https?

Started by nick_sinigamy, Jun 27, 2022, 01:59 AM

Previous topic - Next topic

nick_sinigamyTopic starter

I have purchased SSL certificate for my site.

But I have more than 1 site purchased from go daddy. So whenever I add htaccess file to my site, the other sites, stop working.

What should I do?

I have talked many times to customer support but this problem never gets solved.

My site is working on both URLs http & https.

Suggest something.
  •  

the_architect

To redirect http URLs to https, do the following:

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName www.example.com
    # ... SSL configuration goes here
</VirtualHost>


This snippet should go into main server configuration file, not into .htaccess as asked in the question.

This article might have come up only after the question was asked and answered, but seems to be the current way to go.
  •  
    The following users thanked this post: Sevad

Sevad

Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

etdigital

To make a link to one webpage redirect to the opening of another, add to the file .htaccess the following line:

Redirect 301/ http://example.com/index.html
In the proposed version:
Redirect 301 - an instruction that informs you that the page has been moved permanently;
http://example.com/index.html - the address of the page to which the redirection is taking place.
When using 301 redirects, the site's rating in search engines is preserved.

Redirection to another domain.
In the instance below, a redirect is performed with www.old-domain.com on www.new-domain.com:

RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?old-domain\.com$RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]
RewriteCond sets the condition under which the rule specified in the RewriteRule is executed. Thus, when requesting any webpage www.old-domain.com or old-domain.com the transition to the address will be carried out www.new-domain.com .
  •