Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule for currency symbols

RewriteRule for currency symbols

         

scarything

6:19 pm on Sep 30, 2005 (gmt 0)

10+ Year Member



I'm a noob to mod_rewrite but I have managed to get it working up to a point. I am using it to create search engine friendly urls. For example rather than this

http://www.example.com/index.php?keywords=word

i can now use this

http://www.example.com/index/word

where my rule changes the following parts:

index becomes index.php
/word becomes?keywords=word

and that all works fine except for one circumstance. My problem starts when I allow the keyword search to include currency symbols such as $, £ and €. So that a search for £50 in long format would be:

http://www.example.com/index.php?keywords=£50

(where the browser actually shows http://www.example.com/index.php?keywords=%A350) and is in my simpler format is

http://www.example.com/index/£50

However this does not work as I cannot get the rule to recognise the currency symbol. I am using apache 1.3. Here is my rule

RewriteRule ^(.*)(index)/(.*)$ $1$2.php?keywords=$3 [R]

If anyone has any ideas I'd appreciate the help.

[edited by: jdMorgan at 9:54 pm (utc) on Sep. 30, 2005]
[edit reason] example.com [/edit]

jdMorgan

9:53 pm on Sep 30, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> http://www.example.com/index/£50 ... However this does not work

Please be more specific: What happens when this URL is requested? Error message in the browser? What appears in your server access and error logs?

Also, you are exposing your script by doing a 302 redirect instead of an internal rewrite, which defeats the purpose of 'friendly' URLs. I'd recommend:


RewriteRule ^(.*index)/(.*)$ /$1.php?keywords=$2 [NE,L]

The [NE] flag (NoEscape) may help with your problem, since it will prevent %A350) from being re-encoded as %25A350.
Jim

scarything

2:58 pm on Oct 1, 2005 (gmt 0)

10+ Year Member



Jim,

http://www.example.com/index/£50

gives a page not found error i.e. my rewrite rules are not matching it (because of the £) so the server just doesn't find a page. The external redirect doesn't matter too much as I want to use the "friendly" urls on other sites linking to mine and sometimes my pages don't find their images or stylesheets even though I am using RewriteBase directives.

At the moment I am using a workaround. Instead of £ symbol I use GBP in my links e.g.

http://www.example.com/index/GBP50

and I am sucessfully matching the GBP fine.