title: Apache is redirecting folder to file .html with the same name
body: <p>I'm trying to redirect 404 json fales to 404.json (with "{}" as content). But apache is redirecting folder to a html file with the same folder name and any custom 404.json redirect fails.</p>
  
  <p><strong>File structure:</strong></p>
  
  <ul>
  <li>/example1/</li>
  <li>/example2/</li>
  <li>/example1.html</li>
  <li>/example2/data.json</li>
  <li>/data.json</li>
  </ul>
  
  <p><strong>Working (redirect to 404.html):</strong></p>
  
  <ul>
  <li><a href="http://example.com/example3/" rel="nofollow">http://example.com/example3/</a></li>
  </ul>
  
  <p><strong>Working (redirect to 404.json):</strong></p>
  
  <ul>
  <li><a href="http://example.com/not-exists.json" rel="nofollow">http://example.com/not-exists.json</a></li>
  <li><a href="http://example.com/example3/data.json" rel="nofollow">http://example.com/example3/data.json</a></li>
  <li><a href="http://example.com/example2/data.json" rel="nofollow">http://example.com/example2/data.json</a></li>
  </ul>
  
  <p><strong>Working (open the file):</strong></p>
  
  <ul>
  <li><a href="http://example.com/example1.html" rel="nofollow">http://example.com/example1.html</a></li>
  <li><a href="http://example.com/data.json" rel="nofollow">http://example.com/data.json</a></li>
  <li><a href="http://example.com/example2/" rel="nofollow">http://example.com/example2/</a> (list files in folder)</li>
  </ul>
  
  <p><strong>Not working (default apache 404):</strong></p>
  
  <ul>
  <li><a href="http://example.com/example1/" rel="nofollow">http://example.com/example1/</a></li>
  <li><a href="http://example.com/example1/not-exists.json" rel="nofollow">http://example.com/example1/not-exists.json</a></li>
  <li><a href="http://example.com/example2/not-exists.json" rel="nofollow">http://example.com/example2/not-exists.json</a></li>
  </ul>
  
  <p>It seems apache is redirecting "example1/" to "example1.html", especially when I try to access a file inside the directory like <a href="http://example.com/example2/data.json" rel="nofollow">http://example.com/example2/data.json</a>, shows 404 message:</p>
  
  <blockquote>
    <p><em>The requested URL /example2.html/data.json was not found on this server.</em></p>
  </blockquote>
  
  <p>It happens even without the .htaccess! All the problem because the example1.html file.</p>
  
  <p><strong>htaccess:</strong></p>
  
  <pre><code># Rewrite MOD
  Options +FollowSymLinks
  RewriteEngine On
  
  # If requested resource exists as a file or directory go to it
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule (.*) - [L]
  
  # 404 json
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*)\.json$ 404.json [L]
  
  # 404 page
  RewriteRule . 404.html [L]
  </code></pre>
  
  <p>Maybe it is some apache file mapping configuration but I can't find anything about it. It happens only for deploy server, for localhost it's fine. =/</p>