PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 3, 2022

[FIXED] set base URL dynamicaly in Laravel 5

 February 03, 2022     laravel, laravel-5, php     No comments   

Issue

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.


Solution

In your .env file specify APP_URL=http://example.com/version2



Answered By - Sergei Krivosheenko
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing