L
L
LehaRybkoha2019-08-21 00:08:00
Yii
LehaRybkoha, 2019-08-21 00:08:00

The favicon is not being added, what should I do?

There is a site on yii2, initially the icon was located in the /web/favicon.ico directory and everything worked, then I had to transfer it to the root so that the search engines would index it, but for some reason it says that the file was not found, although the paths are correct, I don’t understand at all than the problem
.htacess file

Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"

RewriteCond %{REQUEST_URI} !^/(web)
RewriteRule ^assets/(.*)$ /web/assets/$1 [L]
RewriteRule ^css/(.*)$ web/css/$1 [L]
RewriteRule ^js/(.*)$ web/js/$1 [L]
RewriteRule ^images/(.*)$ web/images/$1 [L]
RewriteRule (.*) /web/$1

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /web/index.php

Connecting a favicon
<?php $this->registerLinkTag([
        'rel' => 'icon',
        'type' => 'image/x-icon',
        'href' => 'favicon.ico',
    ]);?>
    <?php $this->registerLinkTag([
        'rel' => 'shortcut icon',
        'type' => 'image/x-icon',
        'href' => 'favicon.ico',
    ]);?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ramzesh Halifionakis, 2019-08-22
@LehaRybkoha

1.The favicon needs to be moved to the web folder.
2.In .htaccess in the rules, add the line:
RewriteRule ^favicon.ico$ web/favicon.ico [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question