.htaccess - RewriteCond file exists -


such simple problem htaccess , have never got along.

  1. serve file if exists.
  2. if uri / , if index.html exists serve index.html
  3. 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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -