htaccess的重定向如果URL中包含电子邮件地址 [英] .htaccess redirect if URL contains an email address
问题描述
我想允许的形式清洁网址 domain.com/me@msn.com 应重定向到的 domain.com/?profile=me@msn.com (URL连接codeD或没有)。
I want to allow clean URLs in the form of domain.com/me@msn.com which should redirect to domain.com/?profile=me@msn.com (URL encoded or not).
什么重写规则会实现这一目标?它应该检测到的电子邮件地址重定向URL。
What RewriteRule would achieve this? It should detect an email address in the URL to redirect.
推荐答案
这是痛苦的匹配电子邮件地址与普通EX pressions。该RFC-2822兼容的正则表达式是两页长。只要符合 @
但是,应该足够你的情况。
It's painful to match mail addresses with regular expressions. The RFC-2822 compliant regex is two pages long. Simply matching the @
should, however, suffice in your scenario.
RewriteEngine on
RewriteRule ^((?<!results=).*@.*)$ ?profile=%1 [L]
编辑:确保手动导航到外形= ...
仍然工作通过产生这种情况?
make sure that manually navigating to ?profile=...
still works by asserting this case.
这篇关于htaccess的重定向如果URL中包含电子邮件地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!