简体   繁体   中英

Remove server.php from Laravel routes

I just installed laravel following the instruction on Larvel docs. I chose to use install via composer create project command.

In the routes. php i created a dummy route

Route::get('/', function(){
    return 'Front Page';
});

When i access http://localhost/mysite/ It shows directory listing of mysite folder. However when i use http://localhost/mysite/server.php It runs my route closure.

I also tried alternate .htaccess code provided at Laravel's docs but that doesn't work either.

I want to remove the server.php from url.

Thanks in advance for help.

This behavior is expected and this is how Laravel works. The public folder is meant for assets and is also (supposed to be) the webservers root directory.

If you are working on localhost that is not the case and the root directory contains multiple projects.

In order to get rid of public you would have to change virtual host settings. As mentioned here in the site . The problem with doing virtual hosts is that other projects in localhost will become inaccessible.

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