mod_rewrite international chars challenge!

Discuss practical ways rearrange URLs using mod_rewrite.

mod_rewrite international chars challenge!

Postby zyron » Thu Feb 24, 2005 4:41 am

Have problems with international chars like: ØÆÅ øæå ñ, etc,etc
when using them with mod_rewrite.
I use this rule:
RewriteRule ^/(.*)$ /index.php?$1 [L]

And this does not work either:
RewriteRule ^/(.*)$ /index.php?$1 [L, NE]

Turning it off and writing this manually works:
domain/index.php?q=bø

Using Rewrite, the URL looks like this:
domain/b%C3%B8

This is being displayed instead of 'ø' : 'bø' :o

This would be a correct encoding of 'ø' : '%F8'

Thanks in advance! I running out of ideas here. :(

This works on www.a9.com :P

Zyron
zyron
 
Posts: 2
Joined: Thu Feb 24, 2005 4:39 am

Postby Caterham » Thu Feb 24, 2005 5:30 am

This is being displayed instead of 'ø' : 'bø'
looks like the URL is submitted in UTF-8 encoding by the browser and not decoded.

try in your php script:

Code: Select all
q= utf8_decode($_GET['q']);

and
Code: Select all
RewriteRule ^/(.*)$ /index.php?q=$1 [L,NE]
this RewriteRule is for httpd.conf (ServerConfig and virtualHost context) only and does not work in per-dir context (e.g. .htaccess).

Robert
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

I solved my problem

Postby zyron » Thu Feb 24, 2005 1:43 pm

I solved my problem .. :D

I have the script running on two servers, one with apache 2, so I test it on the other - and there it was
working perfectly.

So I was looking for that AddDefaultCharSet setting. And turn it off.
That seems to solve the problem.

And then I had the same problem on the main page, but after a long time of debugging I found out that I was missing the correct header - so after adding this code, it was working perfectly as well:

header( 'Content-Type: text/html; charset=iso-8859-1' );
zyron
 
Posts: 2
Joined: Thu Feb 24, 2005 4:39 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 52 guests

cron