Bonjour à tous,
Alors voilà, je suis débutant sur Laravel et après avoir parcouru plusieurs forums, je ne suis toujours pas parvenu à résoudre mon problème.
En effet, en souhaitant accéder à la description d'un article via l'URL "http://localhost/mywebsite/public/articles/mon-premier-article", j'obtiens l'erreur suivante :
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
C:\Wamp\www\mywebsite\vendor\laravel\framework\src\Illuminate\Routing\RouteCollection.php
La page d'accueil, elle, fonctionne correctement. J'ai deja modifié plusieurs fois le htaccess sans succès. Le site tourne sous Wamp.
ArticlesController.php
view.blade.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58 <?php class ArticlesController extends BaseController { public function index() { $articles = Article::paginate(5); return View::make('articles.index', compact('articles')); } public function view($slug) { $article = Article::where('slug', $slug)->firstOrFail(); return View::make('articles.view', compact('article')); } public function edit($id) { $article = Article::findOrFail($id); return View::make('articles.edit', compact('article')); } public function update($id) { $article = Article::findOrFail($id); } } ?>
routes.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <h1>{{$article->title}}</h1> <p>{{$articl->content}}</p> <p><a href="{{ URL::route('articles.index'}}">Revenir</a></p>
htaccess
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 <?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 Closure to execute when that URI is requested. | / Route::get('/', array('uses' => 'ArticlesController@index', 'as' => 'articles.index')); Route::get('/articles/{slug}', array('uses' => 'ArticlesController@view', 'as' => 'article.view')); Route::get('/articles/{id}', array('uses' => 'ArticlesController@edit', 'as' => 'article.edit')); Route::get('/articles/{id}', array('uses' => 'ArticlesController@update', 'as' => 'article.update')); ?>
Merci de votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews </IfModule> RewriteEngine On # Redirect Trailing Slashes... RewriteRule ^(.*)/$ /$1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>
Partager