登录  /  注册
php - laravel 路由如何写,才能实现 /post 和 /post/ 指向一个位置?
阿神
阿神 2017-04-10 15:28:36
[PHP讨论组]

现在,/post/总会跳到别的页面,而不是跳到/post的位置。

我的laravel版本是4.2,下面是测试代码。

phpRoute::get('post', function() { return 'w/out slash'; });
Route::get('post/', function() { return 'with slash'; });
phpRoute::get('post/', function() { return 'with slash'; });
Route::get('post', function() { return 'w/out slash'; });

以上两种配置,结果都如下,都是/post/ 301 跳到别的页面,/post页面正常。

curl http://localhost/gitcafe/public/post
with slash
curl http://localhost/gitcafe/public/post/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://localhost/post">here</a>.</p>
</body></html>
阿神
阿神

闭关修行中......

全部回复(4)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 //m.sbmmt.com/ All Rights Reserved | php.cn | 湘ICP备2023035733号