0

To go directly to the controller on my laravel access by accessing :

http://localhost/laravel/public/home

Do i have to dont use /public ? Can I just use :

http://localhost/laravel/home

Is this because the directory is on the public folder that causes this and should be like this?

Thanks

1

1 Answer 1

3

Depends where your instance of Laravel is located, and whether rewrite rules have been set.

Assuming your Apache/nginx document root is /my/dir/ and your public folder is /my/dir/public/ (which makes the Laravel directory /my/dir/laravel/), you will need the /public/.

However, if your root dir is /my/dir/ and your laravel folder is in /my/laravel/, you can rename public to dir and skip using the public part, as it is now mapped to the documentRoot for the webserver.

You can change all the paths in multiple places:

  • The locations of the paths.php file (which defines all the other paths) is in index.php in your public folder
  • The location of all the other paths is defined in paths.php, one by one. The public one is $paths["public"]. You can change this to anything you like and it will impact both Laravel and the Artisan CLI interface. Bear in mind that Laravel does a small directory transformation after the variable is set (still in that file).
Sign up to request clarification or add additional context in comments.

1 Comment

Then why don't you accept the answer, and/or tell us how you solved your problem :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.