Skip to content

Instantly share code, notes, and snippets.

@kongondo
Forked from mandrasch/.htaccess
Created December 17, 2024 06:58
Show Gist options
  • Save kongondo/79d359134547366eb3ed842e450b543e to your computer and use it in GitHub Desktop.
Save kongondo/79d359134547366eb3ed842e450b543e to your computer and use it in GitHub Desktop.

Revisions

  1. @mandrasch mandrasch revised this gist Apr 7, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,8 @@
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>

    # Fixed version, check for HTTP:X-Forward-Proto, found this via
    # .ddev/apache/apache-site.conf -> https://gist.github.com/nurtext/b6ac07ac7d8c372bc8eb
    # Fixed version, check also that HTTP:X-Forward-Proto is off (= http), redirect
    # found this via .ddev/apache/apache-site.conf -> https://gist.github.com/nurtext/b6ac07ac7d8c372bc8eb
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
  2. @mandrasch mandrasch revised this gist Apr 7, 2022. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -3,11 +3,10 @@
    # RewriteRule ^ - [L,R=404]

    # The general rule for redirecting HTTP to HTTPS:
    # Results in "Error too many redirects" in DDEV, because %{HTTPS} is always == off
    # --> Results in "Error too many redirects" in DDEV, because %{HTTPS} is always == off
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} !=on

    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>

  3. @mandrasch mandrasch created this gist Apr 7, 2022.
    21 changes: 21 additions & 0 deletions .htaccess
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    # Debug trick, uncomment to check values:
    # ErrorDocument 404 "Request: %{THE_REQUEST} Referrer: %{HTTP_REFERER}, Host: %{HTTP_HOST}, HTTPS: %{HTTPS}, HTTP:X-Forwarded-Proto: %{HTTP:X-Forwarded-Proto}"
    # RewriteRule ^ - [L,R=404]

    # The general rule for redirecting HTTP to HTTPS:
    # Results in "Error too many redirects" in DDEV, because %{HTTPS} is always == off
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTPS} !=on

    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IfModule>

    # Fixed version, check for HTTP:X-Forward-Proto, found this via
    # .ddev/apache/apache-site.conf -> https://gist.github.com/nurtext/b6ac07ac7d8c372bc8eb
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    </IFModule>