Reputation: 2249
My Yii2 app is located at:
http://www.example.com/myYiiApp/
I want to get that URL from anywhere in my app. But using this:
Url::home(true)
Returns
http://www.example.com/myYiiApp/index.php
Is there are Yii command to return the url without index.php?
Upvotes: 0
Views: 340
Reputation: 2249
Barring a Yii direct command, I will use dirname(Url::home(true))
Upvotes: 0
Reputation: 3008
Have you tried to configure 'urlManager' in 'components' in config/main.php
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
],
Take care that .htaccess is configured in web folder:
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
Upvotes: 1