【问题标题】:How to deploy Laravel Project on web如何在 Web 上部署 Laravel 项目
【发布时间】:2015-09-14 17:29:05
【问题描述】:

我已经开发了一个网站,可以在 URL 上找到它:http://localhost/abc/public/index.php/account/sign-in

我想将部署 URL 更改为 http://localhost/xyz/public/index.php/account/sign-in

如何更改 laravel 中的基本 URL?

我尝试在app 文件夹中更改app.php 中的URL,但它对我不起作用。上传项目后显示 Forbbiden 404 错误。

我的路线

/**
 * Authenticated group
 */
Route::group(array('before' => 'auth'), function() {

    /**
     * Sign Out(get)
     */
    Route::get('/account/sign-out', array(
        'as' => 'account-sign-out',
        'uses' => 'AccountController@getSignOut'
    ));

    /**
     * Delivery Staff Details(GET)
     */
    Route::get('/add-delivery-staff-details', array(
        'as' => 'add-delivery-staff-details',
        'uses' => 'DeliveryStaffController@getDeliveryStaffDetails'
    ));

    /**
     * Delivery Staff Details(POST)
     */
    Route::post('/add-delivery-staff-details', array(
        'as' => 'add-delivery-staff-details-post',
        'uses' => 'DeliveryStaffController@postDeliveryStaffDetails'
    ));

    /**
     * Show Delivery Staff Details to Shop Manager(GET)
     */
    Route::get('/show-delivery-staff-details', array(
        'as' => 'show-delivery-staff-details',
        'uses' => 'DeliveryStaffController@showDeliveryStaffDetails'
    ));

    /**
     * Get Delivery Shaff Id To its Location(GET)
     */
    Route::get('/get-delivery-staff-id', array(
        'as' => 'get-delivery-staff-id',
        'uses' => 'TrackDeliveryStaffController@showGetDeliveryStaffId'
    ));

    /**
     * Get Delivery Shaff Id To its Location(POST)
     */
    Route::post('/get-delivery-staff-id', array(
        'as' => 'get-delivery-staff-id-post',
        'uses' => 'TrackDeliveryStaffController@postGetDeliveryStaffId'
    ));

    /**
     * Track Delivery Staff(GET)
     */
    Route::get('/track-delivery-staff', array(
        'as' => 'track-delivery-staff',
        'uses' => 'TrackDeliveryStaffController@trackDeliveryStaff'
    ));

    /**
     * 
     */
    Route::get('/assign-delivery-task', array(
        'as' => 'assign-delivery-task',
        'uses' => 'DeliveryStaffController@getAssignDeliveryTask'
    ));

    Route::post('/assign-delivery-task', array(
        'as' => 'assign-delivery-task-post',
        'uses' => 'DeliveryStaffController@postAssignDeliveryTask'
    ));



    /**
     * Accept latlong(GET)
     */
    Route::post('/lat-long', array(
        'as' => 'lat-long',
        'uses' => 'TrackDeliveryStaffController@acceptLatLong'
    ));

    /**
     * Accept latlong(POST)
     */
    Route::post('/lat-long-post', array(
        'as' => 'lat-long-post',
        'uses' => 'TrackDeliveryStaffController@postlatLong'
    ));



    /**
     * Show Delivery Staff on Map
     */
    Route::get('/orders', array(
        'as' => 'orders',
        'uses' => 'DeliveryStaffController@getOrders'
    ));

    /**
     * 
     */
    Route::post('/orders', array(
        'as' => 'orders-post',
        'uses' => 'DeliveryStaffController@postOrders'
    ));

    /**
     * Assign Staff From Different Shift to Current Shift(GET)
     */
    Route::get('add-staff-from-different-shift', array(
        'as' => 'add-staff-from-different-shift',
        'uses' => 'DeliveryStaffController@showaAddStaffFromDifferentShift'
    ));

    /**
     * Assign Staff From Different Shift to Current Shift(POST)
     */
    Route::post('add-staff-from-different-shift', array(
        'as' => 'add-staff-from-different-shift-post',
        'uses' => 'DeliveryStaffController@postAddStaffFromDifferentShift'
    ));

    /**
     * Remove Staff From Temp Shift(GET)
     */
    Route::get('remove-staff-from-temp-shift', array(
        'as' => 'remove-staff-from-temp-shift',
        'uses' => 'DeliveryStaffController@showRemoveStaffFromTempShift'
    ));

    /**
     * Remove Staff From Temp Shift(GET)(POST)
     */
    Route::post('remove-staff-from-temp-shift', array(
        'as' => 'remove-staff-from-temp-shift-post',
        'uses' => 'DeliveryStaffController@postRemoveStaffFromTempShift'
    ));

    Route::get('select-area', array(
        'as' => 'select-area',
        'uses' => 'DeliveryStaffController@showSelectArea'
    ));

    Route::post('select-shop', array(
        'as' => 'select-shop',
        'uses' => 'DeliveryStaffController@selectShops'
    ));
    /**
     * Assign pickup area and shop and delivery boy to orders
     */
    Route::get('assign-orders', array(
        'as' => 'assign-orders',
        'uses' => 'DeliveryStaffController@showAssignOrders'
    ));
    Route::get('email', array(
        'as' => 'email',
        'uses' => 'DeliveryStaffController@email'
    ));

//     Route::post('user_Profile/userInfo', 'DeliveryStaffController@selectShops');
});



/**
 * This is Home Controller
 */
Route::get('/', array('as' => 'home', 'uses' => 'HomeController@home'));

/**
 * This is blank Page
 */
Route::get('/blank', function() {
    return View::make('pages.blank');
});


/**
 * Unauthenticated group
 */
Route::group(array('before' => 'guest'), function() {


    /**
     * CSRF request
     */
    Route::group(array('before' => 'csrf'), function() {
        /**
         * Create Account (POST)
         */
        Route::post('/account/create', array(
            'as' => 'account-create',
            'uses' => 'AccountController@postCreate'
        ));
    });
    /**
     * Sign In Account (GET)
     */
    Route::get('/account/sign-in', array(
        'as' => 'account-sign-in',
        'uses' => 'AccountController@getSignIn'
    ));
    /**
     * Sign In Account (POST)
     */
    Route::post('/account/sign-in', array(
        'as' => 'account-sign-in-post',
        'uses' => 'AccountController@postSignIn'
    ));
    /**
     * Forgot Password (GET)
     */
    Route::get('/account/forgot-password', array(
        'as' => 'account-forgot-password',
        'uses' => 'AccountController@getForgotPassword'
    ));
    /**
     * Forgot Password (POST)
     */
    Route::post('/account/forgot-password', array(
        'as' => 'account-forgot-password-post',
        'uses' => 'AccountController@postForgotPassword'
    ));
    /**
     * Create Account (GET)
     */
    Route::get('/account/create', array(
        'as' => 'account-create',
        'uses' => 'AccountController@getCreate'
    ));
    /**
     * Reset Password (get)
     */
    Route::get('/account/reset-password/{code}', array(
        'as' => 'reset-password',
        'uses' => 'AccountController@getResetPassword'
    ));
    /**
     * Reset Password (POST)
     */
    Route::post('/account/reset-password', array(
        'as' => 'reset-password-post',
        'uses' => 'AccountController@postResetPassword'
    ));

    //Route::post('user_Profile/userInfo', 'DeliveryStaffController@selectShops');
    Route::get('/select-shop', array(
        'as' => 'select-shop',
        'uses' => 'DeliveryStaffController@selectShops'
    ));
    Route::post('/select-shop1', array(
        'as' => 'select-shop',
        'uses' => 'DeliveryStaffController@selectshopsaa'
    ));


});

【问题讨论】:

  • 你的 localhost url 设置不正确,即使是你的新设置,通常应该是 localhost/account/sign-in,你一定是在你的路由中的某个地方设置错误,你能发布你的路由吗?
  • http://localhost/xyz/public/account/sign-inhttp://localhost/xyz/public/account/sign-in 有效吗?你在用阿帕奇吗? nginx?像IIS这样的其他Web服务器?查看laravel.com/docs/4.2#pretty-urls
  • 可能我更新了我的问题。现在你可以看到我的路线了
  • 抱歉回复晚了,我不知道你是否有进一步的进展,但你的路线看起来不错,我怀疑你设置网络服务器的方式我建议你做虚拟主机,然后你赢了上网没有问题。如果您在本地环境 stackoverflow.com/questions/27754367/… 上使用 xampp,请查看此指南以查看 laravel 的设置方式,如果这样做,您将获得正确的路径,例如示例 http://laravelproject1.localhost/account/sign-in
  • 也许您会在 [这里][1] 找到答案。这与您的问题相似。 [1]:stackoverflow.com/questions/16683046/…

标签: php laravel-4


【解决方案1】:

你可以尝试下面的命令让你的应用只监听 localhost 和项目名称,所以 base_url 将被视为http://localhost/xyz/

php -S localhost -t public

这应该将您的项目名称作为基本 url。

【讨论】:

    猜你喜欢
    • 2021-01-24
    • 1970-01-01
    • 2021-10-17
    • 2021-09-03
    • 2011-10-08
    • 1970-01-01
    • 2017-11-05
    • 2021-03-22
    • 1970-01-01
    相关资源
    最近更新 更多