【问题标题】:how to make pretty url in laravel 5.2?如何在 laravel 5.2 中制作漂亮的网址?
【发布时间】:2016-12-24 22:20:34
【问题描述】:

我是 laravel 的新手,我只是尝试将每条路由中的 index.php 删除,例如 https://localhost/test/public/index.php/test1https://localhost/test/public/test1 中。 我可以使用 mod_rewrite 代码来解决这个问题,但不起作用。 我在公用文件夹中的 .htaccess 文件中的代码如下:-

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

显示错误

The requested URL /test/public/test1 was not found on this server

【问题讨论】:

标签: php .htaccess mod-rewrite laravel-5.2


【解决方案1】:

试试这个

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php

【讨论】:

  • 感谢您的回答 Mishanon 但它也不起作用。
  • 你安装 mod_rewrite 吗?
  • 是的,我可以启用 mod_rewite。我的操作系统是 Ubuntu 16.04。
猜你喜欢
  • 2016-12-31
  • 2012-08-29
  • 2014-04-22
  • 2014-09-11
  • 2017-07-27
  • 1970-01-01
  • 2017-08-07
  • 1970-01-01
  • 2013-07-03
相关资源
最近更新 更多