apache2 – redirect from http to https with some source-ip-based exceptions

i was migrating a server from http to https. while header-based redirect worked for most of the clients, for some – i had to allow for a transition period where some configuration / code had to be adjusted.

here’s the config that responds with 302 redir to most of the http requests, but for those coming from very specific hosts, still serves content via http:

<VirtualHost *:80>
 ServerName name.of.the.server
 RewriteEngine On
 RewriteCond %{REMOTE_ADDR} !
 RewriteCond %{REMOTE_ADDR} !
 RewriteRule ^(.*)$ https://name.of.the.server/$1

Leave a Reply

Your email address will not be published. Required fields are marked *

(Spamcheck Enabled)