首页 > 解决方案 > 带有 index.php 的 laravel 5.8 路由重定向到根路由

问题描述

如何将localhost:8000/index.php重定向路由到localhost:8000路由或404 status在 laravel 5.8 中,因为localhost:8000/index.php损坏了我所有的 css 链接而不是漂亮的 URL,所有内部链接都是这样的localhost:8000/index.php/about

标签: phplaravelroutes

解决方案


默认情况下,Laravel 提供了正确的 .htaccess,但如果你愿意,你可以尝试另一种方法:只需为这种情况创建一个路由:

Route::get('{file_name}.php', 'YourMainController@yourMainAction')
    ->where('file_name', '[a-zA-Z0-9\-\_]+');

推荐阅读