This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: Replace encoded characters in URL
Author
Message |
Bekker
Newbie


Joined: 19 September 2010
Posts: 2
Posted: 21 September 2010 at 1:19pm

Hello,

I'm looking for a way to replace encoded characters:
a URI with occurences of & should redirect to a URI
using &
a URI with occurences of %3F should redirect to a URI
using ?
a URI with occurences of %3D should redirect to a URI
using =
a URI with occurences of %20 should redirect to a URI
without spaces

For example:
http://www.site.com/page.aspx%3Fa=1%202&b=1%203
should redirect to:
http://www.site.com/page.aspx?a=12&b=13

This code replaces the & with &, but only for the
first occurence:
RewriteCond %{QUERY_STRING} ^(.*)(&)(.*)$
RewriteRule (.*) $1\?%1&%3? [N,NC,R=301]

This code removes %20, but only for the first occurence:
RewriteCond %{QUERY_STRING} ^(.*)(%20)(.*)$
RewriteRule (.*) $1\?%1%3? [N,NC,R=301]

I tried the Optimize flag, but I did not get it working.

How can I make this work?
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 23 September 2010 at 5:59am

Hello,

Please, try using the [NE] flag.

Regards
Andrew
Back to Top
 
Bekker
Newbie


Joined: 19 September 2010
Posts: 2
Posted: 24 September 2010 at 12:46pm

That's indeed much better. Thanks!
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version