mrkarma4ya
2 months ago
206
4
General

App URL not working properly?

Posted 2 months ago by mrkarma4ya

Hello,

I started learning Laravel from Traversy Media's tutorial, so like he taught, I used virtual hosts in XAMPP to point my app public folder "localhost/lsapp/public" to lsapp.com. After the course, I removed the virtual host codes because I needed to work on some other work related projects too.

Now, I'm trying to access the website directly from localhost/lsapp/public, and the website loads, but all the links that I put manually in the views and routes are using just localhost. I have also changed the APP URL in the .env file, and using the URL function returns "localhost/lsapp/public/", the login and register URLS are pointed correctly too, but everything else is broken. I have also cleared the config cache.

Here's what happens:

If I put something like <img src="/storage/images/image1.jpg">, it points to "localhost/storage/images/image1.jpg" instead of "localhost/lsapp/public/storage/images/image1.jpg".

EDIT:

Just as I was writing this post, I tried using <img src="storage/images/image1.jpg"> instead of <img src="/storage/images/image1.jpg"> (removed the first slash in src) and now its working.

It was working properly even with the slash before, when it was working through lsapp.com, could someone tell me the difference between putting the slash and not putting it?

Also, I'm gonna post this and keep it up, in case someone else has the same issue in the future.

Please sign in or create an account to participate in this conversation.