http to https redirection and preserve canonical

Discussion in 'Apache' started by giteshtrivedi, Aug 26, 2014.

  1. #1
    Hi,
    I want to rewrite my all site urls from http to https and also preserve URL canonicalation like all url redirected to http://www. Could you tell me how to achieve this goal?

    Thanks in advance.
     
    giteshtrivedi, Aug 26, 2014 IP
  2. KevJ

    KevJ Active Member

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #2
    Something like this might help, add to .htaccess, in main directory maybe (public_html) works with SUPHP

    
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://www%{HTTP_HOST}%{REQUEST_URI}
    Code (markup):
    Or you could redirect based on traffic to :80
    
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
    Code (markup):
     
    KevJ, Sep 2, 2014 IP