否则.htaccess/ISAPI

发布于 2024-07-26 20:46:08 字数 337 浏览 1 评论 0原文

我想检查 URL 以查看它是否包含多个字符串之一,然后根据该字符串将其发送到不同的 URL。 我是否被迫使用多行,每行对应一种可能性? 或者有没有办法形成一个 if 语句? 我认为这样的东西应该可以工作:

(string1)(string2)(string3) example.com/$1$2$3

因为在我的例子中,永远不会找到多个字符串,所以额外的字符串在重定向的 URL 中将为 NULL。 但是,只有当我想使用字符串本身作为新 URL 的修改部分时,这才有效,但我不这样做。

文件大小多大时我需要开始担心文件加载时间?

有任何想法吗?

谢谢!

I would like to check a URL to see if it contains one of multiple strings, and then based on that, send it to a different URL. Am I forced to use multiple lines, one for each possibility? Or is there anyway to form an if statement? I figured that something like this should work:

(string1)(string2)(string3) example.com/$1$2$3

because in my case, multiple strings will never be found, so the extra strings will be NULL in the redirected URL. however, that only works if I want to use the string itself as the modified part of the new URL, which I do not.

At what file size do I need to start worrying about my file load time?

Any ideas?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寻梦旅人 2024-08-02 20:46:08

您可以在正则表达式中使用简单的替换:

RewriteRule ^/(string1|string2|string3)$ http://example.com/$1

这将匹配路径 /string1/string2/string3

You can use simple alternation in your regular expression:

RewriteRule ^/(string1|string2|string3)$ http://example.com/$1

This would match the paths /string1, /string2 or /string3.

伴梦长久 2024-08-02 20:46:08

您可能想要更像这样的内容:

RewriteRule string1|string2|string3 example.com/$0

正则表达式中的表达式 string1|string2|string3 与三个替代项中的任何一个匹配,并且 $0 当然会替换为任何整个正则表达式匹配。

You'd probably want something more like this:

RewriteRule string1|string2|string3 example.com/$0

The expression string1|string2|string3 in the regex matches any of the three alternatives, and $0 is of course replaced with whatever the entire regular expression matched.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文