将旧版.php网址扩展名移动到Laravel [英] Moving Legacy .php url extensions to Laravel
本文介绍了将旧版.php网址扩展名移动到Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以向laravel路由中添加.php扩展名,如下所示:
Is it possible to add a .php extension to laravel routes like so:
example.com/mypage.php
我正在将一个旧网站转换为Laravel,但不想出于SEO目的而更改URL.
I am transitioning an old website into Laravel but don't want to change the URL for SEO purposes.
我注意到有一个类似的问题适用于路由web.php中的.html文件.即
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?
推荐答案
您可以将其用作
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
这篇关于将旧版.php网址扩展名移动到Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文