我是否缺少旗帜或其他东西?需要 RewriteRule 提示
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?p=$1&l=$2
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ index.php?p=$1&l=$2
如果我执行 site.com/param_one/param_two/ ,则效果很好,但当我省略 param_two 时,会返回 404。我是使用 htaccess 路由请求的新手,有简单的快速修复吗?
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)$ index.php?p=$1&l=$2
RewriteRule ^([a-zA-Z0-9_]+)/([a-zA-Z0-9_]+)/$ index.php?p=$1&l=$2
this works fine if I do site.com/param_one/param_two/, but returns a 404 when I omit param_two. I'm a newbie to routing requests with htaccess, is there a simple quick fix?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
量词
+
表示一次或多次重复。但/param_one/
需要零次或多次重复。因此,请尝试使用*
量词来进行零次或多次重复:The quantifier
+
means one or more repetitions. But/param_one/
would require zero or more repetitions. So try the*
quantifier to have zero or more repetitions: