简体   繁体   中英

Laravel URL Rewrite

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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM