对现有文件的请求执行index.php


Requests to existing files execute index.php

我使用下面的。htaccess代码在网站中启用友好的url。

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?$1 [L]
</IfModule>

代码工作正常,只有一个小异常。当我在浏览器中请求一个文件(即图像)时,浏览器加载它(如我所期望的),但与此同时index.php被执行。

结果是浏览器正在发出GET /favicon.ico请求,由于服务器上没有该名称的文件,根据.htaccess文件中的规则,请求被重定向到/index.php