要求现有文件执行的index.php [英] Requests to existing files execute index.php

查看:145
本文介绍了要求现有文件执行的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用下面的.htaccess code,使友好的网址在一个网站。

I use the following .htaccess code to enable friendly URLs in a website.

<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteBase /

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

</IfModule>

在code正常工作与小例外。当我请求文件浏览器(即图像),浏览器加载它(如我所期望的),但随着该index.php文件被执行。

The code works fine with a small exception. When I request a file in the browser (i.e. an image), the browser loads it (as I would expect), but along with that index.php gets executed.

我不知道为什么。

推荐答案

原来的浏览器正在作出 GET /favicon.ico 请求,因为当时没有文件在服务器上名的基础上,在的.htaccess 文件中的规则,请求被重定向到的index.php

It turned out the browser was making GET /favicon.ico requests and since there was no file with that name on the server, based on the rules in the .htaccess file, the requests were redirecting to /index.php.

这篇关于要求现有文件执行的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆