1499 1842 1403 1916 1907 1198 1336 1950 1146 1025 1392 1320 1484 1994 1808 1912 1377 1689 1113 1430 1741 1589 1401 1685 1266 1920 1865 1488 1747 1760 1810 1973 1743 1655 1894 1355 1455 1090 1502 1990 1479 1668 1368 1223 1829 1008 1776 1473 1882 1473 1373 1363 1327 1954 1580 1676 1993 1605 1691 1554 1685 1230 1928 1077 1604 1935 1446 1705 1119 1800 1212 1936 1941 1654 1241 1718 1355 1987 1071 1419 1814 1682 1379 1220 1669 1143 1745 1908 1229 1345 1265 1789 1169 1600 1750 1273 1747 1311 1306 Apache .htaccess enforce HTTPS | PHPnews.io

PHPnews.io

Apache .htaccess enforce HTTPS

Written by Bram.us / Original link on Feb. 15, 2021

apache-http-server-header.png

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.

bram bram calevans sitepoint bram

« Apache .htaccess trim www. prefix from domain name - Free Early Bird Registration for SPOTcon 2021 Now Open »