I have two versions of a site one running at on example.com and other at example.com/version2.
In web.php I have
Route::group(['middleware'=>['webconfig'],'prefix'=>'version2'], function(){ //Routes for version2 site }); // Routes for main site
In webconfig middleware I set database connection for version2 site. Which is working fine but I am also setting base URL for version2 site. which not working url()
method returns example.com
Here is my webconfig middleware
public function handle($request, Closure $next) { Config::set('database.default', 'mysql_us'); Config::set('app.url', url('version2')); return $next($request); }
So how can I set base url dynamicaly.
Advertisement
Answer
In your .env file specify APP_URL=http://example.com/version2