Skip to content

Instantly share code, notes, and snippets.

@nurtext
Last active May 1, 2023 19:24
Show Gist options
  • Save nurtext/b6ac07ac7d8c372bc8eb to your computer and use it in GitHub Desktop.
Save nurtext/b6ac07ac7d8c372bc8eb to your computer and use it in GitHub Desktop.
Tell apache we're on HTTPS if reverse proxy is serving the site using SSL
# Let apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto "https" HTTPS=on
# Redirect to HTTPS
<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>
@locksmithunit
Copy link

@crapthings
Copy link

i have a nginx that reverse proxy wordpress by https
the wordpress is running by an docker with apache2 inside
but now it redirect between http and https, how to turn off redirect?

@locksmithunit
Copy link

is can be a couple of reasons you need to be more specific.
Do you use Nginx? cPanel? Plesk? Engintron on cPanel?

I can tell you this code is effective for people who have NGINX and reverse proxy.
and I don't gonna lie if you have cPanel has the big chance this code is not recommended anymore.

cPanel design himself (APACHE as well) with new features with an interface (like windows not work on DOS anymore and when you compile it you actually need to do it from the interface).

if you work on the cloud, ssh, and individual WordPress standalone is a little different.
@crapthings
if you use cPanel is be easier to help you, btw good to know for you:
https://support.cpanel.net/hc/en-us

if you have cPanel (even from the hosting is no matter)
connect to the link they are able to help you,

if you have something also like Plesk, cPanel Engintron, stuff like this, more than here I will try help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment