Reputation: 6799
I am using Laravel 5.5
Currently URL::to('/');
outputs http://www.example.com
I want URL::to('/');
to output http://www.example.com/something
Could you please tell me how to implement this ?
Upvotes: 1
Views: 8205
Reputation: 61
First change your application URL in the file config/app.php
(or the APP_URL value of your .env file):
'url' => env('APP_URL', 'http://localhost')
Then, add thoses lines of code to the file app/Providers/AppServiceProvider.php
in the boot method:
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
\URL::forceRootUrl(config('app.url'));
}
}
Upvotes: 6
Reputation:
In the config/app.php
file you can set the base url.
'url' => 'http://www.example.com/something'
Set it using the config
helper to change it programatically.
config(['url' => 'http://www.example.com/something'])
Upvotes: 1