laravel 路由如何写,才能实现 /post 和 /post/ 指向一个位置?
现在,/post/总会跳到别的页面,而不是跳到/post的位置。
我的laravel版本是4.2,下面是测试代码。
<code>php</code><code>Route::get('post', function() { return 'w/out slash'; }); Route::get('post/', function() { return 'with slash'; }); </code>
<code>php</code><code>Route::get('post/', function() { return 'with slash'; }); Route::get('post', function() { return 'w/out slash'; }); </code>
以上两种配置,结果都如下,都是/post/ 301 跳到别的页面,/post页面正常。
<code>curl http://localhost/gitcafe/public/post with slash curl http://localhost/gitcafe/public/post/ <title>301 Moved Permanently</title> <h1 id="Moved-Permanently">Moved Permanently</h1> <p>The document has moved <a href="http://localhost/post">here</a>.</p> </code>
回复内容:
现在,/post/总会跳到别的页面,而不是跳到/post的位置。
我的laravel版本是4.2,下面是测试代码。
<code>php</code><code>Route::get('post', function() { return 'w/out slash'; }); Route::get('post/', function() { return 'with slash'; }); </code>
<code>php</code><code>Route::get('post/', function() { return 'with slash'; }); Route::get('post', function() { return 'w/out slash'; }); </code>
以上两种配置,结果都如下,都是/post/ 301 跳到别的页面,/post页面正常。
<code>curl http://localhost/gitcafe/public/post with slash curl http://localhost/gitcafe/public/post/ <title>301 Moved Permanently</title> <h1 id="Moved-Permanently">Moved Permanently</h1> <p>The document has moved <a href="http://localhost/post">here</a>.</p> </code>
http://stackoverflow.com/questions/22063520/laravel-slash-after-url-re...
会吗?L5 Route
组件的行为我记得是:
- 无论带结尾斜线与否,均视为同一个路由;
- 带斜线的301跳转到不带斜线的(至少对
GET
如此); - 同一个路由指定两次时,后边的覆盖前边的。
以下是测试用例与结果:
Case 1
<code>$ diff my_l5_app/app/Http/routes.php l5_fresh/app/Http/routes.php 22,24d21 </code>
Case 2
<code>$ diff my_l5_app/app/Http/routes.php l5_fresh/app/Http/routes.php 22,24d21 </code>
因为 /post/和/post 是两个路由路径, 要让他俩指向一个位置,分配配置他俩,都指向同一个位置。
Laravel不知道,不过其他路由我都是后边加?的
/post/?

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PHP 8.4 带来了多项新功能、安全性改进和性能改进,同时弃用和删除了大量功能。 本指南介绍了如何在 Ubuntu、Debian 或其衍生版本上安装 PHP 8.4 或升级到 PHP 8.4

Visual Studio Code,也称为 VS Code,是一个免费的源代码编辑器 - 或集成开发环境 (IDE) - 可用于所有主要操作系统。 VS Code 拥有针对多种编程语言的大量扩展,可以轻松编写

本教程演示了如何使用PHP有效地处理XML文档。 XML(可扩展的标记语言)是一种用于人类可读性和机器解析的多功能文本标记语言。它通常用于数据存储

字符串是由字符组成的序列,包括字母、数字和符号。本教程将学习如何使用不同的方法在PHP中计算给定字符串中元音的数量。英语中的元音是a、e、i、o、u,它们可以是大写或小写。 什么是元音? 元音是代表特定语音的字母字符。英语中共有五个元音,包括大写和小写: a, e, i, o, u 示例 1 输入:字符串 = "Tutorialspoint" 输出:6 解释 字符串 "Tutorialspoint" 中的元音是 u、o、i、a、o、i。总共有 6 个元

如果您是一位经验丰富的 PHP 开发人员,您可能会感觉您已经在那里并且已经完成了。您已经开发了大量的应用程序,调试了数百万行代码,并调整了一堆脚本来实现操作

在dcatadmin(laravel-admin)中如何实现自定义点击添加数据的表格功能在使用dcat...

CMS 代表内容管理系统。它是一种软件应用程序或平台,使用户能够创建、管理和修改数字内容,而无需先进的技术知识。 CMS 允许用户轻松创建和组织内容

Laravel计划任务运行无响应排查在使用Laravel的计划任务调度时,不少开发者会遇到这样的问题:schedule:run...
