yii2 and pretty url
unclrd opened this issue · 3 comments
unclrd commented
hi there,
finally got it working and i absolutely love ig-monitoring…
after setting everything up i would get a 404 error on each page… finally figured out that it had to to with enablePrettyUrl.
i followed: https://stackoverflow.com/questions/37598914/pretty-url-in-yii2-not-working
in web.php i had to change:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
],
],
to
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'<controller:\w+>/<action:\w+>' => '<controller>/<action>',
'<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
'<controller:\w+>/<id:\d+>' => '<controller>/view',
],
],
and created an .htaccess file within /web/:
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
jakim commented
Thanks @unclrd
This is because I only use nginx, and this is an apache configuration.
Can anyone else confirm that this configuration works?
I will attach it to the repository.
nokimaro commented