Answer the question
In order to leave comments, you need to log in
Why does yii2 return 404 for many web services?
Hello. Moved yii2 basic application to hosting. I want to add a site to Yandex. Webmaster. When adding, I get a response from the server 404, the same with Google Search Console. Although the site works great. I get the same thing on some other services.
Yii2 deployed trail. way: In the root directory of the domain - everything except the web folder. The web folder itself is expanded into public_html.
For clarity, I am attaching some configs: .htaccess
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{HTTPS} =off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [QSA,L]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
RewriteCond %{REQUEST_URI} (.*/[^/.]+)($|\?)
RewriteRule .* %1.html [R=301,L]
RewriteRule ^(.*)/$ /$1.html [R=301,L]
'urlManager' => [
'class' => 'yii\web\UrlManager',
// Disable index.php
'showScriptName' => false,
'enableStrictParsing' => true,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'contact.html' => '/site/contact',
'index.html' => 'site/index',
'add.html' => 'ad/index',
'ad/subcat.html' => 'ad/subcat',
'<slug:[\w\-]+?>.html' => 'site/index',
'<slug:[\w\-]+?>/<adid:\d+>.html' => 'ad/view',
'<slug:[\w\-]+?>/<slug2:[\w\-]+?>.html' => 'site/index',
'<slug:[\w\-]+?>/<slug2:[\w\-]+?>/<adid:\d+>.html' => 'ad/view',
),
],
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question