Answer the question
In order to leave comments, you need to log in
How to setup urlManager in yii2?
I cleared the cache and did everything as in the documentation, but it turned out that it didn’t work for the link to be shortened
in frontend/config/main.php
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => false,
'showScriptName' => false,
'rules' => [
],
],
RewriteEngine on
# Если файл или директория существуют, использовать их
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# В ином случае - переадресовать на index.php
RewriteRule . index.php
http://hosttraining/frontend/web/site/index
<code>http://hosttraining/frontend/web/index.php?site/index</code>
yii cache/flush-all
Answer the question
In order to leave comments, you need to log in
Your domain should look in the frontend/web folder, where did they come from in the url? In theory, it should be like this: hosttraining/site/index
What you are doing is not safe. For framework files should not be accessible from web. But if you spit on security and common sense, then .htaccess should be at the root of the site. You have this folder in which frontend lies, etc. And accordingly, he should redirect to frontend/web/index.php, but new jokes and problems will begin there.
So urlManager has nothing to do with it at all. Configure the server correctly so that the domain looks in frontend / web
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question