Results 1 to 5 of 5
  1. #1
    chaumi is offline Private Member
    Join Date
    October 2013
    Location
    East Midlands
    Posts
    1,571
    Thanks
    527
    Thanked 811 Times in 591 Posts

    Default http redirect problem

    Getting this on the hsts preload checker............

    http://domain.com` (HTTP) should immediately redirect to `https://domain.com` (HTTPS) before adding the www subdomain. Right now, the first redirect is to `https://www.domain.com/`.


    Everything seems to work/redirect as expected, and I want the www to be the preferred


    This is currently in htaccess.........

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://www.domain.com/$1 [L,R=301]
    RewriteCond %{HTTP_HOST} !^www.domain.com$
    RewriteRule (.*) https://domain.com/$1 [L,R=301]



    I tried adding this (read it somewhere as the solution), and it did nothing.....

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    </ifModule>



    It's not totally beat me (yet), but I can see many hours ahead disappearing rapidly if I continue.....


    Any ideas what I need to rewrite/add to make it work properly?
    Last edited by chaumi; 2 August 2021 at 3:24 am. Reason: addition

  2. #2
    baldidiot is offline Private Member
    Join Date
    January 2010
    Posts
    5,032
    Thanks
    429
    Thanked 2,306 Times in 1,536 Posts

    Default

    I'm not super hot on htaccess but looks like currently you're telling it to redirect everything to the https://www version.

    This bit:

    Code:
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://www.domain.com/$1 [L,R=301]
    Means if it's not https then redirect to the https://www.domain.com/ version of the site.

    The below should redirect to https and preserve the current subdomain (I think):

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    You can then add additional code to redirect to www if you want to.
    onlinegamblingwebsites.com - Formally known as goodbonusguide.

    Gambling Domains: Small clear out of some of the domains we've been hoarding on Dan - see the list here. Prices negotiable, and willing to swap for decent links.

  3. The Following User Says Thank You to baldidiot For This Useful Post:

    chaumi (2 August 2021)

  4. #3
    baldidiot is offline Private Member
    Join Date
    January 2010
    Posts
    5,032
    Thanks
    429
    Thanked 2,306 Times in 1,536 Posts

    Default

    On a side note, I had no idea that you were supposed to redirect to https first and then www, seems a bit daft to do two redirects instead of one if it's not needed.
    onlinegamblingwebsites.com - Formally known as goodbonusguide.

    Gambling Domains: Small clear out of some of the domains we've been hoarding on Dan - see the list here. Prices negotiable, and willing to swap for decent links.

  5. #4
    chaumi is offline Private Member
    Join Date
    October 2013
    Location
    East Midlands
    Posts
    1,571
    Thanks
    527
    Thanked 811 Times in 591 Posts

    Default

    Quote Originally Posted by baldidiot View Post
    I'm not super hot on htaccess but looks like currently you're telling it to redirect everything to the https://www version.

    This bit:

    Code:
    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://www.domain.com/$1 [L,R=301]
    Means if it's not https then redirect to the https://www.domain.com/ version of the site.

    The below should redirect to https and preserve the current subdomain (I think):

    Code:
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    You can then add additional code to redirect to www if you want to.

    933 forum bonus points to Mr BI...it worked!!...and nothing appears to be busted!

  6. #5
    baldidiot is offline Private Member
    Join Date
    January 2010
    Posts
    5,032
    Thanks
    429
    Thanked 2,306 Times in 1,536 Posts

    Default

    Glad it worked, htaccess can be a frustrating little PITA sometimes!
    onlinegamblingwebsites.com - Formally known as goodbonusguide.

    Gambling Domains: Small clear out of some of the domains we've been hoarding on Dan - see the list here. Prices negotiable, and willing to swap for decent links.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •