I have some HTML files which I’d like to place in my web directory so users can access them directly. However, when I do this, it seems that Slim is invoked and the 404 error is triggered. My best guess is that the .htaccess file is responsible for this (I’ve always avoided messing with mod_rewrite, as such I’m totally clueless here); my .htaccess looks like this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
</IfModule>
Does anybody know how I would have to modify this file to allow direct access to *.html files without invoking Slim? Thanks for any insights.
the default rewrite rules do this already.
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f # do not rewrite on existing file
RewriteRule ^ index.php [QSA,L]
My .htaccess was missing the “-f” command but even after adding it I can’t directly access a htm file. I’m a but puzzled …
Thanks for trying to help though.
Apache or NGINX?
I am using this in production so it’s likely a server setting on your stuff.
Apache on a shared hosting environment. For the record, my original .htaccess contained this:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
</IfModule>