否则.htaccess/ISAPI
我想检查 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在正则表达式中使用简单的替换:
这将匹配路径
/string1
、/string2
或/string3
。You can use simple alternation in your regular expression:
This would match the paths
/string1
,/string2
or/string3
.您可能想要更像这样的内容:
正则表达式中的表达式
string1|string2|string3
与三个替代项中的任何一个匹配,并且$0
当然会替换为任何整个正则表达式匹配。You'd probably want something more like this:
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.