Can't route in Laravel framework
Ad
I create an app with Laravel framework in PHP.
I have a problem with routing.
.htaccess file looks like this:
<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]
routes.php:
<?php
get('/', function () {
return view('welcome');
});
get('1', function() { return 'Je suis la page 1 !'; });
get('2', function() { return 'Je suis la page 2 !'; });
When I load http://localhost:63342/game/public/, server loads welcome.blade.php file, so it's okey. But when I want to load http://localhost:63342/game/public/1, I got error: 404 Not Found. I use appache server and I already enabled 'mod_rewrite' action. What can be problem?
Ad
Answer
Ad
I found solution. I enabled mod_rewrite action for apache server in httpd.conf, but problem was, that I didn't set correct directory path in this file for my projects.
It should have looked like this:
DocumentRoot "/Applications/MAMP/htdocs"
<Directory "/Applications/MAMP/htdocs" >
Options Indexes FollowSymLinks
AllowOverride All
</Directory>
Hope, it helps someone in future.
Ad
source: stackoverflow.com
Related Questions
Ad
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
Ad