Chi*_*Cgi 23 php laravel laravel-routing
我有一个文件夹,我放在Laravel网站的/ public文件夹中.路径是:
/public/test
Run Code Online (Sandbox Code Playgroud)
"test"文件夹有一个名为index.html的文件,它只是我想从公共文件夹加载的静态资源(我不想在框架内为此创建一个视图 - 太多无法解释).
我做了这样的路线:
Route::get('/test', function() {
return File::get(public_path() . '/test/index.html');
});
Run Code Online (Sandbox Code Playgroud)
我无法让它发挥作用.我刚收到Chrome的错误,说这个页面有一个重定向循环.
我可以这样访问它:
http://www.example.com/test/index.html
Run Code Online (Sandbox Code Playgroud)
但我不能在任何地方使用.html扩展名.该文件必须显示为:
http://www.example.com/test/
Run Code Online (Sandbox Code Playgroud)
如何在不使用.html扩展名的情况下从Laravel公用文件夹提供单个HTML页面?
小智 22
过去曾经面对这个问题,作为一个肮脏的小技巧,你可以将测试文件夹重命名为其他东西然后更新
return File::get(public_path() . '/to new folder name/index.html');
Run Code Online (Sandbox Code Playgroud)
关键是你的路线网址与公共文件夹之间没有冲突
归档时间: |
|
查看次数: |
28226 次 |
最近记录: |