Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Location
    beijing
    Posts
    258
    Plugin Contributions
    1

    Default how to make http://www.xx.com auto-redirect to https://www.xx.com ,not need to click

    how to make http://www.xx.com auto-redirect to https://www.xx.com ,not need to click

    https://www.xx.com is running well without any problem,
    but if I enter http://www.xx.com which start with http ,it would not auto redirect to https as I hope

    what should I do ?

    I have tried that creating a .htaccess and added the following code into it ,but seems not work

    RewriteBase /


    # ensure https
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    ### WWW & HTTPS

    # ensure www.
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    thanks

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,155
    Plugin Contributions
    11

    Default Re: how to make http://www.xx.com auto-redirect to https://www.xx.com ,not need to cl

    You should always take into account whether your SSL lists www or not.

    If your SSL certificate does NOT contain www:
    Code:
    # Redirect HTTP with www to HTTPS without wwwRewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
    # Redirect HTTP without www to HTTPS without www
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    # Redirect HTTPS with www to HTTPS without www
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule .* https://%1%{REQUEST_URI} [R=301,L]
    
    
    ## 301 Redirects

    If your SSL certificaate DOES contain www:
    Code:
    # Redirect HTTP with www to HTTPS with www
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\. [NC]
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    # Redirect HTTP without www to HTTPS with www
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    # Redirect HTTPS without www to HTTPS with www
    RewriteCond %{HTTPS} on
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    
    ## 301 Redirects

  3. #3
    Join Date
    Apr 2012
    Location
    beijing
    Posts
    258
    Plugin Contributions
    1

    Default Re: how to make http://www.xx.com auto-redirect to https://www.xx.com ,not need to cl

    RewriteEngine on
    # ensure https
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    ### WWW & HTTPS

    # ensure www.
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]



    thanks for reply
    it works now,the total code is above.
    focus on the open source for online shoping website.
    my site: best shop 24h.com

 

 

Similar Threads

  1. Replies: 6
    Last Post: 18 Aug 2010, 10:32 PM
  2. Replies: 5
    Last Post: 27 Apr 2010, 07:56 PM
  3. Replies: 4
    Last Post: 19 Feb 2009, 06:02 PM
  4. http://www.example.com not working
    By John Zwikstra in forum Installing on a Windows Server
    Replies: 8
    Last Post: 31 Aug 2008, 06:13 AM
  5. change address from http://mysite.com to http://www.mysite.com
    By EliseC in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 26 Mar 2008, 03:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR