Ad

Laravel 5 Routing Issue On Redirecting Url

- 1 answer

I am new to laravel runing a project in it,i got error when i enter a module name to url NotFoundHttpException in RouteCollection.php line 161enter image description here

And here is my routes.php file Code:

/*
|--------------------------------------------------------------------------
| 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' => '[email protected]']);
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' => '[email protected]'));

I have .htacces file in my /public folder as:

<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>

Can anyone help me to sort out this, Thanks

Ad

Answer

  1. Enable Mod_rewrite in your Xampp/Wampp's Apache. Go to {xampp_dir/wampp_dir}/apache/conf/httpd.conf and find the line #LoadModule rewrite_module modules/mod_rewrite.so and remove the # before it.
  2. Allow Apache to Overwrite the htaccess file from anywhere. Find the line AllowOverride None and change it to AllowOverride All

Try localhost/Opensupermall/public/SMM The code here points to your views after the public folder. Now,the best practice would be in production to make your server's root folder to point the /public/ folder

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

So you just type your route names after your root directory name.

Ad
source: stackoverflow.com
Ad