简体   繁体   中英

apache directory index file not showing

I want to do 2 things in htaccess:

  1. Strip extension from php files
  2. serve dir/index when url is site/com/dir/

current code

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^([^\.]+)$ $1.php [NC,L]

/dir/ --> /dir/index be default apache behavior, but the rewriteRule break this logic. How to set up rewriteRule for stripping extension from file and not break dir --> dir/index logic?

updating

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

to:

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

solved the issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM