mod rewrite regex help needed

Status
Not open for further replies.

DewChugr

Photoshop God
Jun 26, 2006
1,977
66
0
48.655139,-119.644032
I am trying to get a mod rewrite working, but I need to be able to use some special characters. The characters I need are like this áÌÏüäÒöñá but whe I paste tham in vi I get this á?~L?~Oüä?~Röñá and of course they don't work. Even when I paste just the á in which appears to paste correctly it doesn't work.

I have used these in php in a preg_match with success.

Any help greatly appreciated.
 


Here's my guess:
These characters are encoded into their hex values, in urls.
For example, space ' ' is encoded into '%20'.

i.e. type those into your address bar, and you'll see they're converted.

the string á?~L?~Oüä?~Röñá turns into %C3%A1?~L?~O%C3%BC%C3%A4?~R%C3%B6%C3%B1%C3%A1. Note not all characters convert (i.e. ~ and ? aren't converted).

Using Php's $_SERVER['REQUEST_URI'] variable seems to verify that. So, my guess is you'd replace the characters with the appropriate hex codes in your .htaccess, as that's what the server actually receives.

There's a converter at the bottom of URL Encoding which might help.
 
Thanks Skittled, I agree with what you are saying about the encoding. The characters I'm needing are áÌÏüäÒöñá so the two you mentioned not converting are not a problem.

I've gotten it to work by changing my rewrite to (.*), but I'm not happy with that. I'll give your idea a try.

I'd like to have URLs without encoded characters. While this might not be practical for the few that have the characters I listed above I'd like to rid my URLs of them for spaces ', etc. I can change all of my spaces to dashes, but I have dashes in some of the links so the next script will turn those back into spaces. The

This is my preg_match validation string
/^[a-zA-Z0-9 \(\)\/\"\'\.áÌÏüäÒöñá&#-]{5,80}$/"

Suggestions for the best way to handle these?
 
This is my preg_match validation string
/^[a-zA-Z0-9 \(\)\/\"\'\.áÌÏüäÒöñá&#-]{5,80}$/"

Suggestions for the best way to handle these?
Not off the top of my head. Maybe I missed something, but I'd still be looking at matching the encoded values of those characters.
 
Status
Not open for further replies.