如何从laravel 4中的url中删除index.php

时间:2015-03-07 04:20:04

标签: laravel laravel-4

我希望删除laravel 4.2站点的url中的index.php。但我不知道该怎么做。没有index.php /页面没有加载。我的routes.php包含

Route::get('/', 'HomeController@home');

Route::get('login','HomeController@home');

Route::get('forgotpassword', 'LoginController@ForgotPassword');

Route::post('loginprocess', 'LoginController@loginprocess');

Route::group(array('before' => 'auth'), function()
{
Route::get('locations','LocationController@locations');
Route::get('createlocation','LocationController@createlocation');
Route::post('createlocation','LocationController@savelocation');
Route::get('editlocation/{data}','LocationController@editlocation');
Route::post('editlocation/{data}','LocationController@updatelocation');
Route::get('deletlocation/{data}','VendorController@deletevendor');

Route::post('statusactiveLocation/{data}','LocationController@statusactiveLocation');
Route::post('statusinactiveLocation/{data}','LocationController@statusinactiveLocation');

Route::get('vendors','VendorController@vendors');
Route::get('createvendor','VendorController@createvendor');
Route::post('createvendor','VendorController@savevendor');
Route::get('editvendor/{data}','VendorController@editvendor');
Route::post('editvendor/{data}','VendorController@updatevendor');
Route::get('deletevendor/{data}','VendorController@deletevendor');

Route::post('statusactiveVendor/{data}','VendorController@statusactiveVendor');
Route::post('statusinactiveVendor/{data}','VendorController@statusinactiveVendor');

Route::get('logout', 'LoginController@Logout');
});

1 个答案:

答案 0 :(得分:0)

试试这个......

To remove the “index.php” suffix from the end of your Laravel applications url, use one of the two methods below.

This also works for removing the public from your url

<强>方法1 即可。

At the minimum use the following code and put it in your “public” folder inside an htaccess file. Make the public folder the root of your application.

Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

<强>方法2

 If you do not have access to change you application’s root folder to public, put the following code in your application’s root directory(which presumably is the one where public is contained in) inside of a .htaccess file.

Options -MultiViews
    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ public/index.php [L]