I have a single HTTPS virtual host for all of my websites. I am trying to redirect subsite2.server.co.uk from http to https.
Here is my HTTPS virtual host (I have shortened it for brevity):
<VirtualHost _default_:443>
ServerName *.server.co.uk
ServerAdmin imran.azad@server.co.uk
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.subsite1.server.co.uk$ [NC]
RewriteRule ^(.*)$ http://localhost:8080/VirtualHostBase/https
/www.subsite1.co.uk:443/Plone/VirtualHostRoot/$1 [L,P]
RewriteCond %{HTTP_HOST} ^subsite2.server.co.uk$ [NC]
RewriteRule ^(.*)$ http://subsite2.server.co.uk/$1 [P]
Here is my HTTP virtual host:
<VirtualHost *:80>
ServerName subsite2.server.co.uk
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Alias /static-dir/ x:/.....
<Directory x:/.....>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / x:/......
<Directory x:/......>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
I am using the following rewrite condition and rule to do the redirection:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
However the problem I’m having is that it appears as though the server is in a redirect loop. How can I get around this problem?
Here is an error from firefox:
The page isn't redirecting properly
Mine is working using something similar, my guess is, try using your regex match instead REQUEST_URI