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

cjustado's avatar

url() only returns the base url

Hello,

in my .env file my APP_URL = http://mydomain.com/project_folder. Then in the index method of my controller, I wanted to cache the page by using view()->render().

My problem is in the view that I am using I have this lines

but the rendered result becomes

<link href="http://mydomain.com/assets/css/style.css" rel="stylesheet">
<link href="http://mydomain.com/assets/css/responsive.css" rel="stylesheet">

Why did it on get the base url or the domain name and not the correct value of APP_URL which is http://mydomain.com/project_folder?

How do I fix it so it will return the APP_URL value?

Thanks in advance.

0 likes
11 replies
cjustado's avatar

jlrdw,

 The project is really setup in a subfolder. This is my code in my blade file

and my

APP_URL = http://mydomain.com/project_folder

after rendering the view, this is the result of the above code

I was expecting it to be

What is the problem in my blade code?

Why didn't url() returned the correct APP_URL?

cjustado's avatar

zachleigh,

 No. Because the app should be running in a subfolder. APP_URL is suppose to be where we want the app located, right? That is how I understand about that setting?
cjustado's avatar

jldrw,

But what if the application is just a part of the main website? Do we need to reconfigure the entire website to have it fit with laravel, which is just a small part of a bigger website?
jlrdw's avatar

Yes for security reasons, search this forum there is a lot of topics on this. Google as well as you see more results than Jeffrey shows.

cjustado's avatar

jlrdw,

 Ok. I think that is not a good option in our part. I just thought that frameworks are flexible enough to fit in any cases possible. But thank you so much for your time in attending to my questions.

Cheers :-)

zachleigh's avatar

@cjustado@gmail.com

As far as I know, APP_URL is simply the url of the app. It doenst appear to be used much at all. I just did a grep search through a 5.3 app and the only place it is used is in a package.

My guess would be that you want to change the base path of the application. I believe you can do this in bootstrap/app.php. You'll probably want to change this line:

$app = new Illuminate\Foundation\Application(
    realpath(__DIR__.'/../')
);

Just a guess though....

1 like

Please or to participate in this conversation.