从laravel控制器中删除公众后无法工作?
问题描述:
我已经安装了laravel 5和localhost/laravel/public显示laravel的登录页面。一旦我使用php artisan命令创建控制器hello,并创建如下hello控制器显示未找到页面的htaccess文件。请帮我解决这个错误从laravel控制器中删除公众后无法工作?
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
routes.php文件文件
Route::get('/', function() {
return view('welcome');
});
Route::get('/hello', '[email protected]');
hello.php控制器文件
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class Hello extends Controller
{
public function index()
{
echo "test";
}
}
答
解决自己
简单的方法来从laravel 5删除URL公开。你只需要削减的index.php和的.htaccess公共目录,并将其粘贴在根目录下,多数民众赞成在index.php文件作为
require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
答
这是有趣的,但真正的是控制器不依赖于公众夹。如果您将公用文件夹的文件复制到另一个目录中,并且完全包含index.php中的其他文件,那么它肯定会起作用。
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
更改这两个行的目录,以便index.php可以包含完美的两个文件。
你能告诉我该怎么办呢 –
答案是代替两行为您更新 –