htaccess rewrite causes 500 error instead of 404

前端 未结 3 1784
情深已故
情深已故 2021-01-14 17:11

I\'ve recently added this little bit of code to my .htaccess file:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Rewri         


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-14 17:46

    You should test if new path points to an existing file:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php [L,QSA]
    

    Otherwise you will get an infinite recursion (error 500).

提交回复
热议问题