Laravel 5路由问题重定向网址

时间:2016-01-03 07:40:41

标签: php laravel routing routes laravel-5

我是laravel在其中运行项目的新手,当我在RouteCollection.php第161行输入模块名称为url NotFoundHttpException时出错 enter image description here

这是我的 routes.php 文件代码:

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', ['as' => 'home', 'uses' => 'Landing@index']);
Route::get('/buyerregistration',['as' => 'buyerregistration', function () {
    return view('buyerregistration');
}]);

Route::get('owarehouse/{id}',  ['as' => 'owarehouse',function () {
    return view('owarehouse');
}]);

Route::get('/SMM',  ['as' => 'SMM',function () {
    return view('SMM');
}]);

Route::get('productconsumer/{id}/{openwish_id?}',array(
 'as' => 'productconsumer', 
 'uses' => 'ProductController@productconsumer'));

我的/ public文件夹中有 .htacces 文件:

<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

任何人都可以帮我解决这个问题, 感谢

1 个答案:

答案 0 :(得分:1)

  1. 在Xampp / Wampp的Apache中启用Mod_rewrite。 转到{xampp_dir/wampp_dir}/apache/conf/httpd.conf并找到该行 #LoadModule rewrite_module modules/mod_rewrite.so并删除之前的#。
  2. 允许Apache从任何地方覆盖htaccess文件。找到这条线 AllowOverride None并将其更改为AllowOverride All
  3. 试试localhost/Opensupermall/public/SMM 此处的代码指向公用文件夹后的视图。 现在,最好的做法是在生产中使服务器的根文件夹指向/ public /文件夹

    Route::get('/SMM',  ['as' => 'SMM',function () {
    return view('SMM');
    }]);
    

    因此,您只需在根目录名称后键入路由名称。