url rewriting - Remove .php extensions with .htaccess without breaking DirectoryIndex -
i have following rewrite in .htaccess file removes .php extension files, converting example so.com/question.php so.com/question.
rewriteengine on rewritecond %{request_filename} !-f rewriterule ^([^\.]+)$ $1.php [nc,l]
however breaks default directoryindex behaviour, in typing directory redirect index file in folder, e.g. so.com/answer displays so.com/answer/index.php
simply combining above code directoryindex index.php
not achieve both results.
can me combine these 2 functions, or rewrite code exclude index.php files, achieve same result?
i'm thinking need verify file exists prior doing rewrite, way you'll leave 404 , directoryindex behaviours intact:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename}.php -f rewriterule ^(.*)$ $1.php [nc,l]
(not tested)
Comments
Post a Comment