问题
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