繁体   English   中英

对现有文件的请求执行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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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