Answer the question
In order to leave comments, you need to log in
How to get rid of index.php in Yii2 via urlManager? Why is the server throwing an error?
Everything would be fine, and partially I have already configured the URL through urlManager, but as soon as I add
'showScriptName' => false , the server returns a 500 error on internal pages.
What could be wrong?
Part of frontend/config/main.php code
<?php
'components' => [
//...
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
],
'params' => $params,
];
Options +FollowSymLinks
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
Answer the question
In order to leave comments, you need to log in
The best solution I've used works from here mickgeek.com/yii-2-advanced-template-on-the-same-d... , to be precise, from here https://github.com/mickgeek/yii2- advanced one home...
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php/$1 [L]
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
// ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question