Q: Conditionally set Files directive in .htaccess We have a webpage which is protected by our SSO. However, we also have a mobile app where the user will be authenticated and we want to launch a page on our website without them having to login.
The SSO is engaged via htaccess in a  directive - I want to be able to conditionally enable this rule.
I don't have much experience with htaccess but I am aware of an If directive which I believe we could wrap around the Files directive and inspect the query string of the incoming request - if the query string contains a token - allow access, otherwise enable SSO - this is so that visitors from the web will still have to sign in through SSO.
I can't seem to get the syntax right for the If though, and just get 500s. I have tried...
<If "%{REQUEST_URI} =~ ?referrer=ilancaster ">
  <Files "index.html">
    AuthType SSOModule
    SSOModule On
  </Files>
</If>


A: This works nicely - enables SSO for web visitors, skips it if you pass a token
<Files "index.html">
  <If "%{QUERY_STRING} =~ /^((?!token).)*$/">
    AuthType SSOModule
    SSOModule On
    Require group <group>
  </If>
</Files>

