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

Old_Pigeon's avatar

with or without index.php

Hi, when i'm running like(http://localhost/my-laravel-app/public), it works good, but when i'm running like (http://localhost/my-laravel-app/public/index.php), my css does not work.

you know why? how can i fix that? regards

0 likes
32 replies
Old_Pigeon's avatar

i'm not running that :d i'm just assuming maybe users run like that, so it should be fixed right? by the way thanks for replyng

zachleigh's avatar

I dont think your average user will try to access routes outside of those presented to them in the ui. If users go off the path you define for them in your app, they shouldn't expect much. Just my opinion I guess.

Old_Pigeon's avatar

but this is a bug i guess, thing abut google, google some times show with index.php, and what someone clicks on that link with index.php at the end? i think laravel has something to solve this, normally it should shows the same page with or without index.php

Old_Pigeon's avatar

@Prez, if i set public folder to root, again it gives me the same result. point here is not root. point here is to have 2 different views with index.php and without index.php. if i remove public folder, then when i type localhot/my-app/index.php , again it does not show my css

SaeedPrez's avatar

@Old_Pigeon As you wish, it's your app/headache.

Just change the href to your stylesheet so it looks like /my-laravel-app/public/path/file.css and it should work.

Old_Pigeon's avatar

this is my css code in my master-page < link rel="stylesheet" href="{{ URL::to('src/css/main.css') }}" >

zachleigh's avatar

Google probably shows index.php because those sites arent using a modern routing system. I have several sites up and none of them show index.php in google.

Old_Pigeon's avatar

@ Prez, yes, whn i put this code, then both way does no work. < link rel="stylesheet" href="{{ URL::to('public/src/css/main.css') }}" >

Old_Pigeon's avatar

hey guys, this is not just my app's problem, this is laravel's problem, you can try with your laravel app and see the same result!

SaeedPrez's avatar

@Old_Pigeon don't use {{ URL::to() }}, just put plain text..

<link rel="stylesheet" href="/public/src/css/main.css">
SaeedPrez's avatar
Level 50

@Old_Pigeon plain text path works for me, but with {{ URL::to() }} it doesn't work.

Look to bottom-right of the reply text box, there is a link to info how to format.

Old_Pigeon's avatar

@Prez, i wrongly selected your answer as best answer :D, how can remove that?

Old_Pigeon's avatar

@ Prez, :D, but this topic is not solved yet, i think we should report it to laravel

Old_Pigeon's avatar

why this forum is like this, i can not reply to each post, and there i no rich-text and so on

Old_Pigeon's avatar

@ Prez, i dont know, mine doesn work even with plain, but anyway we should find a way work with laraval code too

Old_Pigeon's avatar

@Prez, no thats not cash, how did you make your public as root folder? lets make it as root with your way and try again

Next

Please or to participate in this conversation.