• Resolved Loc_rabbirt

    (@loc_rabbirt)


    I tried redirect it with this code in my htaccess:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

    But when I tried load my page:

    http://goodlayers.tienloc.net/traveltour/tour/tour-custom-template/

    goodlayers.tienloc.net/traveltour/tour/tour-custom-template/

    Its not redirect/force to https, it just loaded to http with www. Please don’t recommended me to use plugin, I don’t want use plugin so I tried with htaccess.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • anonymized-17844177

    (@anonymized-17844177)

    loc_rabbirt, hi.

    Method #1:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

    http:// >> https:// (+ http://www >> https://)

    Method #2:

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

    Method #3:

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

    Method #4:

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

    Hope it helps 🙂

    Thread Starter Loc_rabbirt

    (@loc_rabbirt)

    Hi,

    If I understand it well, none of methods work with: http > https + www? Could you advice some way to force http > https + www?

    Thread Starter Loc_rabbirt

    (@loc_rabbirt)

    Already resolve with clarify details in StackOverflow

    The code below work for me:

    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+?)\.?$ [NC]
    RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L]
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Http redirect to https with www use htaccess’ is closed to new replies.