Revision #145 has been created by rackycz on Oct 6, 2019, 9:35:42 PM with the memo:
web folder
« previous (#144) next (#146) »
Changes
Title
unchanged
Yii v2 snippet guide
Category
unchanged
Tutorials
Yii version
unchanged
2.0
Tags
unchanged
tutorial,beginner,yii2
Content
changed
[...]
Note that **Yii::$app->request->baseUrl** returns "/myProject/web". No trailing slash.
**How to redirect web to subfolder /web**
---
... to be added on Friday ..Yii 2 has the speciality that index.php is hidden in the web folder. I didnt find in the official documentation the important info - how to hide the folder, because user is not interested in it?
Our demo applicatino is placed in folder:
- C:\xampp\htdocs\basic\web\index.php
Now you will need 2 files named .htaccess
- C:\xampp\htdocs\basic\web\.htaccess
- C:\xampp\htdocs\basic\.htaccess
The first one is mentioned in chapter **Nice URLs**
The second is much simpler:
```
RewriteEngine on
RewriteRule ^(.*)$ web/$1 [L]
```
... it only adds the word "web" into all URLs. But first we have to remove the word from URLs. Open file config/web.php and find section **request**. Add attribute
```
'request' => [
// 'cookieValidationKey' => ...
'baseUrl' => '/basic', // add this line
],
```
Now things will work for you. But it might be needed to use different value for devel and productice web location.
I will test this and if I find problems and solutions I will add them.
**Auto redirection from login to desired URL **
---
... to be added
on Friday ...
**What to change when exporting to the Internet**
---
- Delete file web/index-test.php
- In file web/index.php comment you 2 first lines containing YII_DEBUG + YII_ENV[...]