htaccess rewrite causes 500 error instead of 404

前端 未结 3 1807
情深已故
情深已故 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:36

    First off, here is some reference to better understand the mod_rewrite module:

    mod_rewrite Documentation

    mod_rewrite Cheat Sheet

    The problem you are seeing is that it is checking for both conditions, the default is [AND], when you only want to check for one, try this:

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

提交回复
热议问题