문제

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php

It tries to load a /favicon.ico as a controller because favicon.ico does not exist in my root folder. How would I rewrite the above htaccess to not load favicon.ico as a controller but to ignore it?

It is making an extra request which I do not want it to do.

도움이 되었습니까?

해결책

You can add this to your htaccess to ignore rewriting favicon.ico and anything with the extensions in the parens

RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|ico)$ [NC]

So your htaccess would look like

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|ico)$ [NC]
RewriteRule ^(.*)$ /index.php
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top