Moving Legacy .php url extensions to Laravel

扶醉桌前 提交于 2020-03-05 06:04:15

问题


Is it possible to add a .php extension to laravel routes like so:

example.com/mypage.php

I am transitioning an old website into Laravel but don't want to change the URL for SEO purposes.

I notice there is a similar question that works for .html files in the routing web.php. i.e.

Route::get('mypage.html', function () {
    return 'Hello World';
});

Which works fine but:

Route::get('mypage.php', function () {
    return 'Hello World';
});

returns - No input file specified.

Is there any way to resolve this?


回答1:


You can use it as

Route::get('mypage.php', function () {
    echo 'Hello World';
});

or if you want to return view then use like that

Route::get('welcome.php', function () {
    return view('welcome');
});

Here welcome is your blade file name



来源:https://stackoverflow.com/questions/60055789/moving-legacy-php-url-extensions-to-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!