I'm using Laravel 5.2. I have a simple form on the homepage. When a user clicks search on that form it should send them to a registration page. It's just a dummy form so no data is being submitted. I'm not sure what I need to put in my routes file. Do I need to put something in my controllers file as well? I have already created the register blade. Any help will be appreciated.
@zachleigh I even tried to do it with the anchor that you mentioned but I keeping the following error message. The welcome and register view are in the same folder.
"Not Found
The requested URL /register was not found on this server."
The following is my routes.php...
Route::get('/', function () {
return view('welcome');
});
Route::get('register', function () {
return view('register');
})->name('register');
I don't have that file. This is all being ran on a Ubuntu distro. The welcome route works jut fine. If I make that that register route the homepage it works fine as well.
You don't have a .htaccess file located at public/.htaccess?
Laravel comes with one so it was either deleted or not uploaded when you installed the app of your server.
Create the file with content from the laravel repo. https://github.com/laravel/laravel/blob/master/public/.htaccess
You will also need to make sure your vhost has AllowOverride All for the public directory.
The welcome view is my homepage. Do you want me to put that code there?
No, put it in public/index.php which is the frontcrontroller that all requests that aren't static files should be running.
The file should look like the following https://github.com/laravel/laravel/blob/v5.2.29/public/index.php
If you don't see test then the apache rewrite rules aren't sending requests to this script which would cause only the welcome route to show.
@spekkionu For some reason I can't get these views to open in a browser just by opening the register.blade.php file.
With exit('test') in the index.php I'm no longer able to open up the homepage though.
Edit: I was finally able to open that file, but I don't see exit being displayed in the window. Only the content of the view. Also I changed the .conf file to AllowOverride All
When I said to open the register route in the browser I did not mean the view file. I meant the url the route is pointing to which looks like /register.
What you see when you open up the homepage should be what you see for every url.
Because you don't that means the problem is likely your server configuration and has nothing to do with your routes, controllers, or views.
You can remove the exit statement you added as that was just a test.
Try to make sure your document root is pointed at your public directory and not the root of the application.
Because you said you were able to open your view file in the browser and the views directory is outside the public directory you likely have this pointed at the wrong place.
@spekkionu The problem is solved. After running "sudo a2enmod rewrite" and restarting the apache server the routes are now found. I don't understand what that command does but I will google it. Thanks for all of your help.