简体   繁体   English

Laravel路线网址?

[英]Laravel route url?

I have just completed the Basic Task List laravel tutorial. 我刚刚完成了基本任务列表laravel教程。 But when i click on "Add task" button the url i get is http://localhost/task instead of http://localhost/laravel5.1/public/task which it should be. 但是,当我单击“添加任务”按钮时,我得到的URL是http:// localhost / task而不是应该的http://localhost/laravel5.1/public/task I have searched a bit but i could find an answear you to make the url pointing correctly. 我搜索了一下,但是我可以找到一个正确的URL指向您。 By the way i had forgoten to add the Application URL in the config/app.php. 顺便说一句,我已经放弃将应用程序URL添加到config / app.php中。 I added it, and creared cache with the php artisan cache:clear command but still nothing. 我添加了它,并使用php artisan cache:clear命令php artisan cache:clear但仍然没有执行任何操作。 My laravel version is 5.1 . 我的laravel版本是5.1。

Reason : You should configure your application first and generate url properly 原因:您应该首先配置应用程序并正确生成URL

How : Inside config/app.php set the 'url' => ' http://youraddresshost ' 如何:config/app.php设置'url'=>' http:// youraddresshost '

Note : 注意 :

Changing the public folder as root in your apache is not the better solution, it won't work if you are moving the project to live server and you have multiple projects in it. 将公用文件夹更改为apache中的root并不是更好的解决方案,如果将项目移动到实时服务器并且其中有多个项目,则无法使用。

So, You should Generate your url in Laravel way ie, via helper so that you can pointed to the correct destination. 因此,您应该以Laravel方式(即通过帮助程序)生成您的网址,以便您可以指向正确的目的地。

Read more about Generating URL with laravel here 在此处阅读有关使用laravel生成URL的更多信息

Even you can do this to generate the url as suggested here 即使您可以按照此处的建议执行此操作以生成网址

echo url('user/profile');

echo url('user/profile', [1]);

Also, if you do some jquery function to redirect the url on button click, you should generate url accordingly. 另外,如果您执行一些jquery函数来重定向单击按钮时的url,则应相应地生成url。

Hope, this helps you 希望对您有帮助

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

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