Add custom apache settings for ssl/non-ssl only?

Discussion in 'General' started by sjau, Apr 8, 2016.

  1. sjau

    sjau Local Meanie Moderator

    Is there a way to add custom directives through ISPC to apache that appear only in the non-/ssl vhosts?
     
  2. Jesse Norell

    Jesse Norell Active Member

    Untested, but you could probably just put the same directive in both and use <If> to run the right one.
    Code:
    <If "%{HTTPS} == 'on'">
      ssl stuff.....
    </If>
    <Else>
      non-ssl stuff....
    </Else>
    https://httpd.apache.org/docs/current/expr.html
     
    Last edited: Apr 14, 2016
  3. sjau

    sjau Local Meanie Moderator

    That might be just what I need :)
     
  4. sjau

    sjau Local Meanie Moderator

    Ok, this works:
    Code:
    <If "%{HTTPS} == 'off'">
        Redirect permanent / https://sub.domain.tld/
    </If>
    
    I think I have to adjust my le2ispc script since it's recommended to use Redirect permanent ;)

    This means rewrite conditions aren't needed anymore hence less trouble with different rewrites :)
     
    Jesse Norell likes this.
  5. sjau

    sjau Local Meanie Moderator

    Hmmm, I tried to get it running and I used it now like:
    Code:
    <If "%{HTTPS} == 'off'">
        Redirect permanent / https://%{HTTP_HOST}
    </If>
    
    since the old
    Code:
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    
    also worked fine.

    I ended now up with a vhost file like this: https://paste.simplylinux.ch/view/71c2c03c which looks all fine.
    However if I do call that domain in the browser, I don't end up at https://domain.tld but at https://%{http_host}
     
  6. Jesse Norell

    Jesse Norell Active Member

    Dunno, I'm not familiar enough with where % expands work and don't.
    That clearly says old URL-path is %-decoded, but doesn't as clearly say that the new URL isn't %-decoded, though that could certainly be inferred. Your results would seem to confirm that.
     
  7. sjau

    sjau Local Meanie Moderator

    Nah, the problem is that the %{HTTP_HOST} var is only available in rewrite operations :(
     

Share This Page