Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 - Wrong homeUrl when setting baseUrl in urlManager

I have a site is in a "web" subfolder, that is hidden with .htaccess so that people accessing http://www.example.com gets served with http://www.example.com/web/index.php .

To set this behaviour and prevent Yii2 from generating links with the "web" folder, I have set "baseUrl" to "/" in the urlManager.

Now all the pages are served right, and all the links are created correctly, but the Yii::$app->homeUrl variable has an incorrect value "//" when it should be "/", so it creates problems with login/logout.

If i remove the baseUrl it works correctly, but adding the "web" parent folder to all urls.
What am I doing wrong?

like image 463
Roberto Avatar asked Dec 02 '25 18:12

Roberto


1 Answers

Had same trouble. I just added 'homeUrl' => '/' option to config root.

like image 179
Yurik Avatar answered Dec 04 '25 07:12

Yurik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!