use*_*820 11 laravel laravel-4
当我使用secure_url()或时asset(),它链接到我的网站的域名没有 "www",即"example.com".
如何更改链接到"www.example.com"?
Syn*_*ynn 38
首先在文件config/app.php(或.env文件的APP_URL值)中更改您的应用程序URL :
'url' => 'http://www.example.com',
Run Code Online (Sandbox Code Playgroud)
然后,让URL生成器使用它.在引导方法中将几行代码添加到文件app/Providers/AppServiceProvider.php:
\URL::forceRootUrl(\Config::get('app.url'));
// And this if you wanna handle https URL scheme
// It's not usefull for http://www.example.com, it's just to make it more independant from the constant value
if (\Str::contains(\Config::get('app.url'), 'https://')) {
\URL::forceScheme('https');
//use \URL:forceSchema('https') if you use laravel < 5.4
}
Run Code Online (Sandbox Code Playgroud)
这就是所有人.
| 归档时间: |
|
| 查看次数: |
39872 次 |
| 最近记录: |