[users@httpd] mod_rewrite Special % character problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

example.com/folder/apples%2526oranges/more

Will give GET variable 'vara' a value of '&'. However going to:
example.com/script.php?vara=%2526&varb=more

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,
Saqib

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux