I’m currently using the below script which I found online:
#########################################
#### BEGIN EDIT FOR MOD_REWRITE ####
#### This is intended to force HTTPS ####
#### for all inbound HTTP requests ####
####
# This module (mod_rewrite) simply tells Apache2 that all connections to
# port 80 need to go to port 443 . SSL . No exceptions
####
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine on
####
# The line below sets the rewrite condition for mod_rewrite.so.
# That is, if the server port does not equal 443, then this condition is true
####
RewriteCond %{HTTPS} !=on
#ReWriteCond %{SERVER_PORT} !^443$
####
# The line below is the rule, it states that if above condition is true,
# and the request can be any url, then redirect everything to https:// plus
# the original url that was requested.
####
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]
#### END EDIT FOR MOD_REWRITE ####
#######################################
The script is added to my httpd.conf file which runs on an CentOS server in a LAMP stack. It does exactly what I need it to, which is to redirect all traffic to any of the sites on the server to https.
However, I would like to make an exception for one of the sites hosted on the server which does not need to use https. How can I go about configuring this exception?
My apologies for what may an elementary question as I’m not a developer by trade.
Thanks in advance!
Figured it out. Had to add the line below as a RewriteCond:
RewriteCond %{HTTP_HOST} !^www\.example\.com*