htaccess 重定向仅当它在正斜杠后有值时 [英] htaccess redirect only if it has value after forward slash

查看:31
本文介绍了htaccess 重定向仅当它在正斜杠后有值时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅当 /events/

如果我访问 /events/(不要做任何事情.不要应用 htaccess 规则)

If I visit /events/ (Don't do anything. DO NOT apply the htaccess rule)

但是如果我访问/events/this-can be-anything/(应用下面的htaccess规则)

But if I visit /events/this-can be-anything/ (Apply the htaccess rule below)

RewriteRule ^events/(.*) /lp/events/index.php [L]

这显然不起作用.

推荐答案

您需要将正则表达式模式 (.*) 更改为 (.+) 以匹配 uri 后至少一个字符.

You need to change your regex pattern (.*) to (.+) to match at least one character after the uri.

RewriteRule ^events/(.+)$ /lp/events/index.php [L]

这篇关于htaccess 重定向仅当它在正斜杠后有值时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆