My Yii2 app is based on advanced template. I created CRUD for a model named Navigation
in backend side.
Now when I try to open domain.com/navigation/index
getting Unable to resolve the request navigation/index
.
For information I placed this snippet in common/config/main.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
What am I doing wrong?
You have to create a .htaccess file with the following:
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
# 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
</IfModule>
<IfModule php5_module>
php_value session.cookie_httponly true
</IfModule>
There are several problems possible. Maybe your VM doesn't allow pretty URL than you could test your crud at least.
Just adjust the script Url for your needs as well as the other options
'urlManagerBackend'=>[
'enablePrettyUrl' => false,
'class' => 'yii\web\UrlManager',
'scriptUrl' => '/admin',
'baseUrl' => 'http://localhost/admin',
],
For any trouble here is the forum post: http://www.yiiframework.com/forum/index.php/topic/60118-creating-links-from-backend-to-frontend-and-frontend-to-backend/page__fromsearch__1
Another problem could be that you are using auth rules or that your controller is in the wrong folder. Or the view file not in the folder navigation.
But first try disabling pretty URL to point out if it is server side problem or with the scripts
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.