Apache .htaccess enforce HTTPS

Because I have to look this up from time to time, a note to myself: Add the contents below to your .htaccess to have Apache enforce HTTPS while preserving the rest of the URL (domain name, querystring, etc). RewriteEngine On # Enforce HTTPS (everywhere) RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] ~


This content originally appeared on Bram.us and was authored by Bramus!

Because I have to look this up from time to time, a note to myself: Add the contents below to your .htaccess to have Apache enforce HTTPS while preserving the rest of the URL (domain name, querystring, etc).

RewriteEngine On

# Enforce HTTPS (everywhere)
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

~

Did this help you out? Like what you see?
Thank me with a coffee.

I don't do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

☕️ Buy me a Coffee (€3)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2021-02-15T12:30:25+00:00) Apache .htaccess enforce HTTPS. Retrieved from https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/

MLA
" » Apache .htaccess enforce HTTPS." Bramus! | Sciencx - Monday February 15, 2021, https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/
HARVARD
Bramus! | Sciencx Monday February 15, 2021 » Apache .htaccess enforce HTTPS., viewed ,<https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/>
VANCOUVER
Bramus! | Sciencx - » Apache .htaccess enforce HTTPS. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/
CHICAGO
" » Apache .htaccess enforce HTTPS." Bramus! | Sciencx - Accessed . https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/
IEEE
" » Apache .htaccess enforce HTTPS." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/. [Accessed: ]
rf:citation
» Apache .htaccess enforce HTTPS | Bramus! | Sciencx | https://www.scien.cx/2021/02/15/apache-htaccess-enforce-https/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.