rewriterule in htaccess to match certain file extensions

前端 未结 2 2161
一个人的身影
一个人的身影 2021-02-13 13:08

How can I look for an instance for certain file extensions, like .(jpg|png|css|js|php), and if there is NOT a match send it to index.php?route=$1.

I would like to be abl

2条回答
  •  灰色年华
    2021-02-13 13:38

    Have you tried reversing the logic? Something like

    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule \.(jpg|png|css|js)$ - [L]
    

    This will not do a rewrite for any file with a .jpg, .png, .css, or .js extension. Then add your existing rules so that non-file, non-directory requests get rerouted to index.php.

提交回复
热议问题