简体   繁体   English

Laravel路由URL问题

[英]Laravel Routing URL issue

I am not so sure what is wrong with the following issue (I am using PHP with laravel). 我不太确定以下问题出了什么问题(我在laravel中使用PHP)。 I have a main template with header and footer. 我有一个带有页眉和页脚的主模板。 I have a view (Register) for creating some request (view, controller and model). 我有一个用于创建某些请求(视图,控制器和模型)的视图(注册)。 Everything is fine so far. 到目前为止一切都很好。 Now, I am trying to add an edit view and created a new view (RegisterEdit - same as previous view) but just with values populated for the given id. 现在,我试图添加一个编辑视图并创建一个新视图(RegisterEdit-与以前的视图相同),但是只填充了给定ID的值。 In this new view, all the links (header and footer) on the page are wrongly pointed. 在此新视图中,页面上的所有链接(页眉和页脚)均指向错误。

In the old view, the link to home page is like this: 在旧视图中,首页链接如下所示:

  mywebsite.com/home

But in the edit view, this is being changed to 但是在编辑视图中,这已更改为

mywebsite.com/RegisterEdit/home

Following are my routes. 以下是我的路线。

Route::get('Register', 'CreateRequestController@Page_Load');
Route::post('Register', 'CreateRequestController@CreateRequest');
Route::get('RegisterEdit/{id}', 'CreateRequestController@Page_Load');
Route::post('RegisterEdit', 'CreateRequestController@CreateRequest');

Any idea, what could be wrong here? 任何想法,这可能是什么问题?

To create urls in your code you should use URL::to , for example: 要在代码中创建url,您应该使用URL::to ,例如:

<a href="{{ URL::to('home')">Home page</a>

or you should add in your <head> section of your header: 或者您应该在标题的<head>部分中添加:

<base href="http://mywebsite.com/">

(trailing slash is required here after domain name). (在域名后必须在后面加上斜线)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM