Redirect URL with % symbol

I understand that the percent symbol (%) is an illegal/reserved character for URIs, but my client has packaging printed with this URL.

For example, [B]http://www.example.com/1%[/B] (the URL printed on packaging) needs to redirect to [B]http://www.example.com/causes[/B].

I am using WordPress, and although it allows the use of a percent symbol within the page title, the permalinks DOES NOT allow use of the percent symbol. This leads me to believe that modification to the .htaccess rewrite rules is my only potential solution.

I’ve searched this forum and see no straight forward way of doing this. Can someone tell me what blurb of code (rewrite rule) to insert into my .htaccess that would allow this specific page to be redirected properly?

This is kind of urgent. Any help is much appreciated.

Regards,

Chris

Chris,

First, WELCOME to SitePoint!

Second, I dislike providing “script kiddie” code but it does seem like you’re in a quandry because of a “stupid client.” As you’re aware, % is a reserved character because it specifies that encoding data follows (i.e., a space is displayed as %20). I suspect that you can capture (and delete) the % by escaping the % character within a character range definition and redirecting without the offending %.

Since you’re asking about mod_rewrite (whether you knew that or not), I have to ask how mod_rewrite is supposed to determine that it needs to request causes based on “1” (or “1%”). To me, that implies that you have a RewriteMap installed OR need to make a rather long series of redirections based on digits (WP is better than that!).

If you need more information about mod_rewrite, may I suggest the link in my signature - then you know where to find me to ask (PM) questions.

Please note that I do not consider you a “script kiddie” but, as the former Team Leader here, I considered it “bad form” to ask for others to code for you as well as for SP member webmasters to use code they do not understand. Of course, this is a personal thing with me so please don’t take offense where none was intended.

Regards,

DK

Thanks for the response…I think. I do not claim to be a developer (I know enough to make me dangerous), but I will forward your response onto my developer. In short, you can call me a “script kiddie”, but I don’t find that insulting because I’m sure you are are a “kiddie” in a lot of other areas where I’m a “master”. ; )

Regardless, I sincerely appreciate your response.

My suspicion (based solely on my limited php coding knowledge) is that this is something that can be handled in .htaccess and therefore would leverage mod_rewrite functionality. How to code it is what I’m asking for help with. If that is against forum rules, I apologize, but I’m a bit desperate to try anything at this point.

P.S. I have no idea what a RewriteMap is, but I’m sure my developer does.

My point of posting to this forum is to find assistance from someone with deeper knowledge like yourself. I’m not asking for someone to code it for me…just provide me with an explanation and (God willing) a sample. I’ll take it from there. Sorry if that is in bad taste. That was not my intent.

Thanks for the response. I’ll post a follow up response to let you know how it goes.

Regards,

Chris

I’m wondering if it might be easier to url encode the percent symbol as hex %25

I think I found the solution…which is a little quirky on the WordPress side. When you name a page “1%” it automatically converts that permalink URL to “1-1”. When you try to override the permalink setting by manually typing “1%” and then save, it reverts back to “1-1”. HOWEVER, when you encode “1%” (resulting in “1%25”) and THEN paste it in the permalink setting, it converts it to “1%”.

So, this means my problem is SOLVED.

Thanks for all your input.