Difference between #121 and #122 of
Yii v2 snippet guide

Revision #122 has been created by rackycz on Oct 4, 2019, 7:28:30 AM with the memo:

nice urls
« previous (#121) next (#123) »

Changes

Title unchanged

Yii v2 snippet guide

Category unchanged

Tutorials

Yii version unchanged

2.0

Tags unchanged

tutorial,beginner,yii2

Content changed

[...]
**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 **
---
[...]
2 0
1 follower
Viewed: 10 699 times
Version: 2.0
Category: Tutorials
Written by: rackycz
Last updated by: rackycz
Created on: Sep 19, 2019
Last updated: 23 days ago
Update Article

Revisions

View all history