【问题标题】:Only "/" route is working in my Laravel Application只有“/”路由在我的 Laravel 应用程序中有效
【发布时间】:2015-08-17 20:12:10
【问题描述】:

这是我的路线:

    Route::get('/', 'WelcomeController@index');

    Route::get('home', 'WelcomeController@index');

    Route::controllers([
        'auth' => 'Auth\AuthController',
        'password' => 'Auth\PasswordController',
    ]);

这是我的 WelcomeController:

   <?php namespace App\Http\Controllers;

   class WelcomeController extends Controller {

    /*
    |--------------------------------------------------------------------------
    | Welcome Controller
    |--------------------------------------------------------------------------
    |
    | This controller renders the "marketing page" for the application and
    | is configured to only allow guests. Like most of the other sample
    | controllers, you are free to modify or remove it as you desire.
    |
    */

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }

    /**
     * Show the application welcome screen to the user.
     *
     * @return Response
     */
    public function index()
    {
        return view('welcome');
    }

  }

视图很简单..

我输入 /home 的结果是这样的:

为什么我做错了?

与 Apache/xampp 有关吗?我只是不知道..我在主文件夹中再次安装了作曲家,没有任何改变。

所以,如果有人可以帮助我,我会很高兴

【问题讨论】:

  • 您是否创建了虚拟主机?把你的 htaccess 文件也放上。
  • 就像@itachi 提到的那样。检查您的 htaccess 设置。从您的 URL 手动下降到公共目录,通常将您的虚拟主机设置为指向公共目录,而不是像这样访问公共,因为您正在公开您的应用程序根目录
  • 添加路由后有没有尝试清除路由缓存? (php artisan route:clear)

标签: php apache laravel routes laravel-5


【解决方案1】:

您在浏览器中访问的网址不正确。从屏幕截图中可以看出,您去了web-service/public/home。您在浏览器中输入的网址应该是:

web-service/public/index.php/home

或者,如果您启用了漂亮的 url(启用了 url 重写),您可以转到:

web-service/home

【讨论】:

    猜你喜欢
    • 2015-10-04
    • 2018-02-07
    • 2016-11-15
    • 2021-05-02
    • 2014-04-27
    • 2021-08-05
    • 1970-01-01
    • 1970-01-01
    • 2019-02-15
    相关资源
    最近更新 更多