nor pretty URLs:
It even fails to serve the default controller and action -- site/index
.
What am I missing?
It seems that I have everything that I need. Following the guide I have:
- Created the micro-framework application skeleton
- Created default controller (
site
) and default action (index
) - Configured
db
component, run migrations and created database - Created PostController
- Enabled routing by adding Yii code to application configuration (see code example above) and by creating corresponding .httaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
What else must I do in order to make the whole thing work or what am I missing here? Thanks!
CodePudding user response:
Remove this line:
'enableStrictParsing' => true,
CodePudding user response:
This question comes from an misunderstanding. I wasn't aware that when pretty URLs are enabled then yii\rest\UrlRule::$pluralize
is set to true by default. Meaning that the request must be:
http://localhost/micro-app/posts
(plural controller name; notice "s" at the end)
Not:
http://localhost/micro-app/post
(singular controller name)
It is also completely normal that when pretty URLs are enabled then regular URLs doesn't work anymore. That's the reason for getting 404 File Not Found on http://localhost/micro-app/index.php?r=post
URL when pretty URLs are enabled.