RewriteRule with Email Address

Tag: regex , .htaccess , mod-rewrite Author: wangqinbaby Date: 2011-04-26

I am trying to do a RewriteRule that can include an email address. I think something is wrong with my regular expression.

RewriteRule ^user/verify/([[email protected]]+)/([a-zA-Z0-9]+)/?$ user.php?email=$1&token=$2 [L]

Anyone have any thoughts?

Looking for this:[email protected]/sdfdsfa7dfs6dsfa6dsf8/

Best Answer

Use your rule like this:

RewriteRule ^user/verify/([^/]*)/(.*)/?$ user.php?email=$1&token=$2 [L,NC]

This will capture everything between user/verify/ and sdfdsfa7dfs6dsfa6dsf8/ as email address.

Other Answer1

One obvious reason that comes to mind is that you're looking for[email protected]/sdfdsfa7dfs6dsfa6dsf8/

But your regex says

^user/verify/([[email protected]]+)/([a-zA-Z0-9]+)/?$

But maybe that's just an error in your question?

As for the email address, there were already many many discussions on this topic: regex+email. There could be email adresses not matching your regex, e.g. with a + (plus sign) in them.


I fixed up that type.
@ATLChris, what about the /verify?