首页 > 解决方案 > 除特定字符串外,每个 URl 的 RegEx 合规性

问题描述

如果通过 URL 重写与国家不匹配,我想自定义 URL 的货币。

我当前在 Apache 上的重写规则如下所示:

RedirectMatch permanent "^/(.*)_DE/(?!.*(EUR))(.*)$" "https://localhost/$1_DE/EUR$2"

因此 URL https://localhost/de_DE/USD必须更改为https://localhost/de_DE/EUR,但不幸的是该规则不适用。

有 Apache RegEx 的网络测试器吗?regex101.com 似乎并不适合 Apache。

标签: regexapacheurl-rewriting

解决方案


最终的正则表达式是:

RedirectMatch permanent "^/(.*)_DE/((?!.*EUR)[A-Z{3,3}]+)(.*)$" "https://localhost/$1_DE/EUR$3"

感谢您对网站的帮助


推荐阅读