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>
The code works fine with a small exception. When I request a file in the browser (ie an image), the browser loads it (as I would expect), but along with that index.php gets executed.
I wonder why.
事实证明,浏览器正在发出GET /favicon.ico
请求,并且由于服务器上没有该名称的文件,根据.htaccess
文件中的规则,请求被重定向到/index.php
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.