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

Demers94's avatar

Could not open input file: artisan after messing up with the files

I was trying to remove the /public from the URL and found a StackOverflow answered that said that you could take the .htaccess from the /public folder and place it at the root, and then rename your server.php to index.php.

I tried it and it worked, but I noticed that the artisan commands stopped working.

I reverted back to the initial state, by deleting the .htaccess in the root and renaming index.php to server.php, but it's still not working, I get this error :

Could not open input file: artisan

Is there anything I can do to fix this, or do I have to start a new project from scratch and copy over my files?

0 likes
7 replies
phildawson's avatar

Whilst StackOverflow is full of helpful people, it's just that everyone thinks they know what they are doing.

Ideally it should be set as the root so you shouldn't have public in the url at all. Is there a reason for removing the public in the url?

Demers94's avatar

@pmall I know, but I never replaced them, I simply renamed server.php to index.php. Now that I renamed it back to server.php, I don't know why it's not working, since the content is exactly the same as it was before.

Nonetheless I redownloaded a fresh copy of both files from the Github, but it's not working still.

@phildawson

I wanted to remove it from the URL so that it's prettier. The reason I want to figure it out now on this test project is that I'm planning to make another bigger project with Laravel.

It will be a subsection (subfolder) of an existing project, so it will look like this :

  • MainProject
    • File 1
    • File 2
    • File 3
    • Subfolder (Laravel project)
      • app/
      • public/

The URL for the second project would be something like this :

www.mydomain.com/subfolder/public/

And what I want :

www.mydomain.com/subfolder

I read that you can change the webroot, but since it's a subfolder of an existing project, I'm not sure if that will work.

Demers94's avatar

@phildawson I've edited my answer just above yours, I don't know if you're received the notification.

phildawson's avatar

I would def recommend just making a subdomain for the Laravel project

laravelproject.mydomain.com
Demers94's avatar

@phildawson I'll see if that's possible, if not then I've seen somewhere that I can move the files from the /public folder to the root of my project, move everything else in another folder (ex: /app) and then change the different paths of the application.

Would that work?

I've also seen a trick with the .htaccess file that you create at the root of the laravel project, but I never got it to work.

Please or to participate in this conversation.