Help with 301 redirect .htaccess

Discussion in 'BlackHat Lounge' started by strawhat150, Aug 27, 2016.

  1. strawhat150

    strawhat150 Jr. VIP Jr. VIP

    Joined:
    Jan 29, 2014
    Messages:
    195
    Likes Received:
    49
    Gender:
    Male
    Occupation:
    bhw
  2. eridonvevo77

    eridonvevo77 Regular Member

    Joined:
    Aug 27, 2015
    Messages:
    311
    Likes Received:
    47
    Gender:
    Male
    Location:
    Albania
    You can do it with Yoast Seo Wordpress.
     
  3. SebWgnr

    SebWgnr Registered Member

    Joined:
    Apr 19, 2016
    Messages:
    75
    Likes Received:
    60
    I see that you use "X-Forwarded-Proto" so I'm guessing you use Cloudflare, if it's the case just create a page rule to force https.
    If you don't use Cloudflare you can use that:
    Code:
    RewriteEngine On
    RewriteCond%{HTTPS}!=on
    RewriteRule^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
     
  4. dannyvriens

    dannyvriens Registered Member

    Joined:
    Apr 3, 2010
    Messages:
    91
    Likes Received:
    32
    # First rewrite to HTTPS:
    RewriteCond %{HTTPS} off

    # No www in the RewriteRule this is already include in
    # the subsequent rule will catch it.
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Now, rewrite any request to the wrong domain to use www.
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]