Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kikoliner's avatar

Domain is used instead of APP_URL

I have tried to change app_url in ENV file but it is being ignored. Instead Laravel uses whatever I config Apache to set as base domain (for example localhost:8887). As soon as I changed Apache config Laravel composes every single URL with Apache base domain (pointing to public folder).

In RouteServiceProvider I added

public function boot() {

parent::boot();

$url = $this->app['url'];

$url->forceRootUrl(config('app.url'));

}

to finally make it work the way I want. But of course I don't want to leave it without understanding what is really happening. What am I missing? Thank you.

0 likes
6 replies
Cronix's avatar

Are you by chance using config caching (recommended on production)? Did you try php artisan config:clear? If they're cached, you'd have to run that anytime you change something in .env or config files.

kikoliner's avatar

I have already tried to clean config cache but it isn't solving the issue. Thank you anyway.

Cronix's avatar

What does the code look like where you are generating these urls that don't use app.url that you set?

Snapey's avatar

For http routes, the urls returned by the framework will reflect the URL that you accessed the site with.

kikoliner's avatar

So it is normal behaviour.

Thank you very much, Cronix and Snapey, for your help.

Snapey's avatar

Just to complete the picture, APP_URL is used when needing to generate routes to your application from jobs, for example sending an email with links on a schedule rather than as a result of an http request

1 like

Please or to participate in this conversation.