我搜索了答案,并没有发现任何对我有用的东西。 我有桌子'文章'在哪里我用“slug”来存储文章。列。
在我的路线档案中,我有路线:
当我输入例如/ article / some-article-title并且文章将会显示时,Route :: get(' article / {slug}',' ArticleController @ viewArticle');
工作正常,但我想从/ some-article-title访问。我试图改变路线,如:
路由:: get(' {slug}',' ArticleController @ viewArticle');
当我把它放在文件的末尾时,这是有效的,但毕竟WYSIWYG现在可以正常工作(上传文件),并且一些图像停止工作(404错误)。我试过modyfing .htaccess文件但仍然无法正常工作。
有什么想法吗?
我想像这样创建锚
<a href="http://www.domain.com/some-title-for-article">some-title-for-article</a>
但现在链接看起来像这样:
<a href="http://www.domain.com/articles/some-title-for-article">some-title-for-article</a>
路由文件web.php
Route::get('/', 'HomeController@index');
/* DEPLOY BITBUCKET */
Route::get('/deploy/', 'DeployController@index');
Route::post('/deploy/update',
['as' => 'deploy_update', 'uses' => 'DeployController@update']);
/* ADMIN PANEL */
Auth::routes();
Route::get('/admin/', 'AdminController@index');
/* ADMIN USERS */
Route::get('/admin/users', 'UserController@index');
Route::get('/admin/users/add/', 'UserController@add');
Route::post('/admin/users/create/', 'UserController@create');
Route::get('/admin/users/edit/{id}', 'UserController@edit');
Route::post('/admin/users/update/', 'UserController@update');
Route::delete('/admin/users/delete/{id}', 'UserController@delete');
/* ADMIN CATEGORIES */
Route::get('/admin/categories', 'CategoryController@index');
Route::get('/admin/categories/add/', 'CategoryController@add');
Route::post('/admin/categories/create/', 'CategoryController@create');
Route::get('/admin/categories/edit/{id}', 'CategoryController@edit');
Route::post('/admin/categories/update/', 'CategoryController@update');
Route::delete('/admin/categories/delete/{id}', 'CategoryController@delete');
/* ADMIN COMMENTS */
Route::get('/admin/comments', 'CommentController@index');
Route::get('/admin/comments/view/{id}', 'CommentController@view');
Route::get('/admin/comments/add/', 'CommentController@add');
Route::post('/admin/comments/create/', 'CommentController@create');
Route::post('/admin/comments/approve/{id}', 'CommentController@approve');
Route::delete('/admin/comments/delete/{id}', 'CommentController@delete');
/* ADMIN ARTICLES */
Route::get('/admin/articles', 'ArticleController@index');
Route::get('/admin/articles/view/{id}', 'ArticleController@view');
Route::get('/admin/articles/edit/{id}', 'ArticleController@edit');
Route::get('/admin/articles/add/', 'ArticleController@add');
Route::post('/admin/articles/create/', 'ArticleController@create');
Route::post('/admin/articles/approve/{id}', 'ArticleController@approve');
Route::delete('/admin/articles/delete/{id}', 'ArticleController@delete');
Route::post('/admin/articles/update/', 'ArticleController@update');
Route::post('image-upload','ImageController@imageUploadPost');
/* GALLERIES */
Route::get('/admin/galleries', 'GalleryController@index');
Route::get('/admin/galleries/view/{id}', 'GalleryController@view');
Route::get('/admin/galleries/edit/{id}', 'GalleryController@edit');
Route::get('/admin/galleries/add/', 'GalleryController@add');
Route::post('/admin/galleries/create/', 'GalleryController@create');
Route::post('/admin/galleries/approve/{id}', 'GalleryController@approve');
Route::delete('/admin/galleries/delete/{id}', 'GalleryController@delete');
Route::post('/admin/galleries/update/', 'GalleryController@update');
/* IMAGE CONTROLLER */
Route::delete('/admin/images/delete/{id}', 'ImageController@delete');
Route::get('/admin/images/info/{id}', 'ImageController@info');
Route::post('/admin/images/update/', 'ImageController@update');
/* CONTACT FORM */
Route::get('/kontakt/', 'ContactController@index');
Route::post('/kontakt/',
['as' => 'contact_send', 'uses' => 'ContactController@send']);
/* GALLERY UPLOAD */
Route::post('/gallery_upload/', 'GalleryController@upload');
/* ARTICLE CONTROLLER */
Route::get('{slug}', 'ArticleController@viewArticle')->name('view.article');
//Route::get('artykuly/{slug}', 'ArticleController@viewArticle');
答案 0 :(得分:0)
请问您是否可以尝试使用路线名称为您的路线添加名称?
像这样:
Route::get('{slug}', 'ArticleController@viewArticle')->name('view.article');
并在您的Blade文件中创建锚点:
<a href="route('view.article')"
答案 1 :(得分:0)
由于您没有使用路由名称,只需使用url()
帮助程序:
{{ url('some-title-for-article') }}