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} !10.2.1.10
 RewriteCond %{REMOTE_ADDR} !10.3.11.2
 RewriteRule ^(.*)$ https://name.of.the.server/$1
 [..]
</VirtualHost>

Leave a Reply

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

 

(Spamcheck Enabled)