Yii v2 snippet guide

Comparing #121 with #122

Revision #122 was created by rackycz rackycz on Oct 4, 2019, 7:28:30 AM.

nice urls

Content

[...]
**Nice URLs**
---
Just uncomment section "urlManager" in config/web.php .. htaccess file is already included in the basic demo. In case of problems see [this link](https://stackoverflow.com/questions/26525320/enable-clean-url-in-yii2).

My problem was that images were not displayed when I enabled nice URLs. Smilar discussion [here](https://stackoverflow.com/questions/39197583/image-is-not-passing-in-carousel-in-yii2). 
 
 
```php
 
// Originally I used these img-paths:
 
<img src="..\web\imgs\myimg01.jpg"/>
 
 
/// Then I had to chage them to this:
 
Html::img(Yii::$app->request->baseUrl . '/imgs/myimg01.jpg')
 
 
// The important change is using the "baseUrl"
 
```
 
 
Note that **Yii::$app->request->baseUrl** returns "/myProject/web". No trailing slash.
 
 
**How to redirect web to subfolder /web**
---
... to be added on Friday ...

**Auto redirection from login to desired URL **
---
[...]