简体   繁体   English

正则表达式和mod_rewrite

[英]Regex and mod_rewrite

I'm trying to figure out how to write the correct regular expression when the url has question marks inside. 我试图弄清楚当url带有问号时如何编写正确的正则表达式。

The url : 网址

http://example.com/?s2=1ce05156af2162c654b25a6e0491223269?lang=en

The rewrite I have made but not working 我进行了但未生效的重写

RewriteRule ^s2=[A-Za-z0-9.-]+\?lang=en\b /subscription-confirmation/?lang=en [L,R=301]

Important that it looks for ?s2= and ?lang=en 查找?s2= and ?lang=en

I use mod_rewrite to do the redirect. 我使用mod_rewrite进行重定向。

How do I match the regex so it actually matches similar to the one above? 我如何匹配regex ,使其实际上与上面的匹配?

This worked for me: 这对我有用:

RewriteCond %{QUERY_STRING} ^s2=[A-Za-z0-9.-]+\?lang=en 
RewriteRule .*$ /subscription-confirmation/?lang=en [L,R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM