.htaccess - RewriteCond file exists -
such simple problem htaccess , have never got along.
- serve file if exists.
- if uri / , if index.html exists serve index.html
- otherwise serve app.php
here .htaccess:
# disable directory processing, apache 2.4 directoryindex disabled xxx rewriteengine on # serve existing files rewritecond %{request_filename} -f rewriterule .? - [l] # / serve index.html if exists rewritecond %{request_uri} ^/$ rewritecond index.html -f rewriterule .? index.html [l] # otherwise use front controller rewriterule .? app.php [l]
it works if comment out rewritecond index.html -f line long index.html in fact exists. want check index.php need file exists check. , if nothing else i'd understand why posted lines not work.
this should work:
# disable directory processing, apache 2.4 directoryindex disabled xxx rewriteengine on # serve existing files rewritecond %{request_filename} -f rewriterule ^ - [l] # / serve index.html if exists rewritecond %{document_root}/index\.html -f [nc] rewriterule ^/?$ index.html [l] # otherwise use front controller rewriterule ^ app.php [l]
remember rewritecond
-f
or -d
needs full path file or directory that's why need prefix filename %{document_root}/
.
Comments
Post a Comment