Gmane
Favicon
From: Ramon Felciano <felciano <at> yahoo.com>
Subject: Unescaping backreferences in mod_rewrite to embed email address in url?
Newsgroups: gmane.comp.apache.user
Date: 2008-10-09 05:18:21 GMT (12 weeks, 5 days, 22 hours and 17 minutes ago)

Hi --

Is it possible to have mod_rewrite unescape backreferences? I would like to allow users to access resources through a user-specific URLs, created by embedding a user-provided email address in the URL:

/docs/testuser <at> yahoo.com

I have a form that allows users to enter their email and submits a GET to a CGI:

http://www.example.com/cgi-bin/test.cgi?email=testuser%40yahoo.com

I've created a mod_rewrite rule to trap the above pattern and rewrite it:

RewriteCond %{QUERY_STRING} email=([\w <at> 0123456789%\.]+)$
RewriteRule ^/cgi-bin/test.cgi /docs/%1 [PT]

The above is not a very sophisticated email match, but works for this example. This gives me:

/docs/testuser%40yahoo.com

Is there a way to tell mod_rewrite to un-escape the matched backreference so I get the <at> sign in the URL instead of %40?

Thank you in advance!

Ramon