title: How to make Basic Auth exclude a rewritten URL
body: <p>I have a Basic Authentication setup on a development server. It is setup inside my <code>httpd.conf</code> file for the VirtualHost of the website. I've had to set up it to exclude certain directories, which has caused no problems and all works fine.</p>
  
  <p>The issue has been with excluding a URL that has been through my <code>mod_rewrite</code> rules in the <code>.htaccess</code> file. My set up is that I have all URLs going through my <code>index.php</code> file and from there the relevant code is found and ran. I tried adding the URL that I wanted to exclude (<code>/businesses/upload_logo</code>) like I did the others but it still requires authentication. This is what I currently have:</p>
  
  <pre><code>...
  &lt;Location /&gt;
      SetEnvIf Request_URI "/businesses/upload_logo" noauth=1
      SetEnvIf Request_URI "/api/.*" noauth=1
  
      AuthType Basic
      AuthName "Private"
      AuthUserFile ****
      Require valid-user
  
      Order deny,allow
      Satisfy any
      Deny from all
      Allow from env=noauth
  &lt;/Location&gt;
  ....
  </code></pre>
  
  <p>I have found questions that are similar to mine <a href="https://stackoverflow.com/questions/8338567/disable-http-auth-for-specific-rewritten-location">here</a> &amp; <a href="https://stackoverflow.com/questions/8978080/htaccess-exclude-one-url-from-basic-auth">here</a> but the answers only give me what I'm already trying.</p>
  
  <p>I have thought of possible other solutions as well, but these will be last resort things. I want to see if it's possible the way I'm currently doing it:</p>
  
  <ul>
  <li>Set up the basic auth inside my php code instead
  
  <ul>
  <li>Too much hassle at the moment</li>
  </ul></li>
  <li>Put the authentication in my <code>.htaccess</code> file instead
  
  <ul>
  <li>Didn't want to do this just yet as I only want the authentication to happen on one of 3 servers. I'm aware that I could use some more <code>SetEnvIf HOST ...</code> but I'm looking to see if it can be fixed this way or not first.</li>
  </ul></li>
  </ul>
  
  <p>The <code>mod_rewrite</code> rule:</p>
  
  <pre><code>...
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*) index.php [L,QSA]
  </code></pre>