httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Saqib Kadri" <>
Subject [users@httpd] mod_rewrite Special % character problems
Date Wed, 05 Oct 2005 14:50:28 GMT
Hello all,

I'm having problems with rewriting URLs that contain the special
character codes for ampersands and forward slashes - %26 and %2F.
Rewriting other special characters, like %20, %21, etc., doesn't cause
any problems; but these two (and perhaps others) do, as
mod_rewrite/.htaccess seem to "pre-decode" them. i.e., it thinks that
%2F is an actual backslash (thus giving 404 errors and such).

A solution is to always use '%25' instead of '%'; e.g., placing %2526
and %252F in the URL. Because mod_rewrite seems to "pre-decode" the %25
it will interpret these as %26 and %2F; however, this leads to further
problems, as a direct, un-Rewritten link will not pre-decode the %25.

e.g., given the following in .htaccess:
RewriteRule ^folder/(.*)/(.*) script.php?vara=$1&varb=$2
(with or without [NE] flag)

The URL of:

Will give GET variable 'vara' a value of '&'. However going to:

Will give 'vara' a value of %26. This leads to potentially problematic
issues during programming, e.g. the programming of internal links, and
decoding of GET variables.

Is there any way to resolve this issue? Also, why does mod_rewrite treat
certain character codes (%26, %2F) differently from others - and are
there any more characters that mod_rewrite has trouble decoding, like
%26 and %2F?

Many thanks,

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message