1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Redirect to https:// from non-SSL

Discussion in 'Site & Server Administration' started by jaguar34, Jun 15, 2020.

  1. #1
    What should be the code in .htaccess for redirecting to https version of website from Non-SSL? The website is html based
    SEMrush
     
    Solved! View solution.
    jaguar34, Jun 15, 2020 IP
    SEMrush
  2. #2
    
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 
    
    Code (markup):
     
    qwikad.com, Jun 15, 2020 IP
    sarahk and jaguar34 like this.
  3. seomanualsubmission

    seomanualsubmission Well-Known Member

    Messages:
    469
    Likes Received:
    57
    Best Answers:
    1
    Trophy Points:
    150
    #3
    Yes this is perfect ..... You can add some more like ensure that site is opening with www or without www ...... permanently redirect from http to https etc. Take a look at below code with some additional parameters.

    Options +FollowSymLinks
    RewriteEngine on
    # ensure www. (If prefer without www then remove this section)
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    # ensure https
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    Code (markup):
     
    seomanualsubmission, Jun 15, 2020 IP
  4. qwikad.com

    qwikad.com Illustrious Member Affiliate Manager

    Messages:
    6,410
    Likes Received:
    1,369
    Best Answers:
    24
    Trophy Points:
    400
    #4
    The greedy regex (.*) does that. It matches the URL with or without www. and/or http://

     
    qwikad.com, Jun 16, 2020 IP