H
H
hollanditkzn2018-03-15 15:47:54
Yii
hollanditkzn, 2018-03-15 15:47:54

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' => [
            ],
        ],

And in frontend/web/.htaccess
RewriteEngine on

# Если файл или директория существуют, использовать их
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# В ином случае - переадресовать на  index.php
RewriteRule . index.php

Then when I click on the link, it still doesn’t work http://hosttraining/frontend/web/site/index
, but it only turns out like this to access the page
<code>http://hosttraining/frontend/web/index.php?site/index</code>

Why is this happening and also cleared in yii2 cache with the commandyii cache/flush-all

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2018-03-15
@webinar

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 question

Ask a Question

731 491 924 answers to any question