0

I have an ISPConfig 3 site running on one domain. I have multiple vhost files for the different applications I run through Apache. I want to enable https://example.com/%QUERY_STRING% on every request that come through Apache with that domain. Right now, I have to paste

RewriteEngine on
RewriteCond %{HTTPS} ^off$
RewriteRule . https://example.com%{REQUEST_URI} [R,L] 

RewriteEngine on
RewriteCond %{HTTPS} ^on$
RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteRule . https://example.com%{REQUEST_URI} [R,L] 

in every one of my vhosts. If I had to do this once, it wouldn't be a problem, but I constantly wipe my server and rebuild it from scratch (I have good reasons). I don't like going through all the vhosts and pasting this in every one, I know there must be a more technical way to do this. I tried putting this in my apache2.conf but this does not work. Also I can't turn on SSLEngine unless we are in a <Location> or <Directory> or something like that.

How do I do this?

1 Answer 1

0

Just put in your apache2.conf

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://example.com$1 [R,L] 

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.example\.com
RewriteRule (.*) https://example.com$1 [R,L] 
3
  • That doesn't work.
    – ashraj98
    Jan 5, 2016 at 20:15
  • What happened ? Do you have rewrite log ? What is your 443 port virtual host configuration ?
    – Froggiz
    Jan 5, 2016 at 21:39
  • 1
    It seems that this code is good inside the virtualhost, not in apache2.conf. Moving this into <VirtualHost *:80> and <VirtualHost *:443> works. Thanks!
    – ashraj98
    Jan 6, 2016 at 0:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .