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 ^(开发者_JAVA百科.*)$ index.php?$1 [L]
</IfModule>
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.
I wonder why.
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
.
精彩评论