Laravel:如何路由到公共文件 [英] Laravel: How to Route to Public file
本文介绍了Laravel:如何路由到公共文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Laravel中,是否可以通过路由重定向到public/testFile.php
?
In Laravel, is it possible to redirect to a public/testFile.php
, through routing?
在application/routes.php
中,
Route::get('/', function()
{
//'How to point to public/testFile.php'
});
已经有一个项目,但只想在Laravel中做NEW MODULES.因此,将现有项目复制到Public/
推荐答案
这样做会完全破坏框架的目的,但是如果您真的想要...
You are completely defeating the purpose of the framework by doing this, but if you really want to...
Route::get("/", function() {
ob_start();
require(path("public")."testFile.php");
return ob_get_clean();
});
这将返回文件的标准输出.相反,如果脚本中已经有一个返回值,则敲除ob_start
和return
调用.
This will return the stdout output of the file. If instead you have a return value already in the script, knock out ob_start
and the return
call.
重定向操作如下:
Route::get("/", function() { return Redirect::to("testFile.php"); });
这篇关于Laravel:如何路由到公共文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文