【问题标题】:Laravel Url generating issueLaravel Url 生成问题
【发布时间】:2017-01-05 23:33:04
【问题描述】:

当我放这个

     <a href="{{ Route('admin.edit', $consignment->id )}}" >...</a>

我得到这个链接:localhost:8000/dashboard/edit?3

我想让网址像:localhost:8000/dashboard/edit/3

我该怎么办? 你能帮帮我吗?

【问题讨论】:

  • 你运行的是 nginx 还是 apache?
  • 我正在使用 Xampp Server Apache

标签: php url routes laravel-5.3


【解决方案1】:

在切换到 nginx 之前,我遇到了类似的问题,当使用 apache 时,我似乎丢失了漂亮的 url,我必须做两件事来修复它。首先在您的public/ 目录中创建一个.htaccess 文件并将其作为内容:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>

第二件事是我的项目根文件夹中有一个server.php,我不得不将其重命名为index.php 在不了解项目的所有细节的情况下很难确定可能是什么发生了,但这对我来说完全相同的问题。祝你好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-10
    • 2023-03-14
    • 2015-04-10
    相关资源
    最近更新 更多