Ad

Laravel Route Controller Issue

- 1 answer

I am trying to add a new route to my application and can't seem to get it to work. I keep getting a 404 error. It looks like the physical path is looking at the wrong directory. Currently looking at D:\Web\FormMapper\blog\public\forms but should be looking at D:\Web\FormMapper\blog\resources\view\layout\pages\forms.blade.php

My request URL:

http://localhost/FormMapper/           /works fine
http://localhost/FormMapper/forms      /doesn't work
http://localhost/FormMapper/forms.php  /No input file specified.

my FormsController:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class FormsController extends Controller
{
    public function index()
    {
        return view('layouts.pages.forms');
    }
}

My web.php:

Route::get('/', function () {
    return view('layouts/pages/login');
});
Route::get('/forms', '[email protected]');

My folder structure looks like this: enter image description here

My config/view.php

return [
'paths' => [
    resource_path('views'),
],

'compiled' => env(
    'VIEW_COMPILED_PATH',
    realpath(storage_path('framework/views'))
),
];
Ad

Answer

After tracking digging deeper I determined that the issue was that IIS requires URL rewrite rules in place for Laravel to work properly. The index.php and '/' route would work b/c it was the default page but any other pages wouldn't. To test this I used the

php artisan serve

approach to it. and everything worked properly. Unfortunately I am unable to do this in production so I needed to get it to work with IIS.

Ad
source: stackoverflow.com
Ad