Skip to content

Instantly share code, notes, and snippets.

@mdpuma
Last active July 30, 2026 12:23
Show Gist options
  • Select an option

  • Save mdpuma/db089e5f108f7d4dc457 to your computer and use it in GitHub Desktop.

Select an option

Save mdpuma/db089e5f108f7d4dc457 to your computer and use it in GitHub Desktop.
nginx + apache, http to https redirect
Require ip 185.181.228.28 89.28.17.33
# cat httpd.conf
SetEnvIf X-Forwarded-Proto https HTTPS=on
# cat .htaccess
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTP_USER_AGENT} ".*meta-externalagent/1\.1.*" [OR]
RewriteCond %{HTTP_USER_AGENT} ".*meta-webindexer/1\.1.*" [OR]
RewriteCond %{HTTP_USER_AGENT} ".*ClaudeBot/1\.0.*"
RewriteRule .* - [F,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment