views:

27

answers:

1

Hi, I'm trying to work with special chars in URLs but I have some trouble on undertand what I shuld do to get it works correctly.

I've saw URLs like:

http://www.last.fm/music/Simon+&+Garfunkel
http://www.last.fm/music/小林武史

works perfectly on Last.FM, but how can I do that?

I've asked at this question some way to do it, but has solved my problem partially thanks the regex post in .htacess file (.+?), but I still have problems on read the url.

If i write something like http://mysite.com/event/Dance&Jump and use in my php page:

//.htaccess
RewriteEngine On
RewriteRule ^(event/)(.+?)[/]?$ event.php?event_name=$2

<?
    print urldecode ($_REQUEST["event_name"]);
?>

the page will print:

//<html> printed page

    Dance // "&Jump" is missing, how can I fix it?

//</html> printed page

I'd like to be able to work with almost all special chars like Last.FM or Wikipedia

How are the tecniques to work with special char url and the common procedures?

+1  A: 

Try the B flag:

RewriteRule ^event/(.+?)/?$ event.php?event_name=$1 [B]
Gumbo
thank you very much, can you be so gentle to give me some link which exlain the [B] command or simply give some explanation by you? thanks again!
Vittorio Vittori
@Vittorio Vittori: When the *B* flag is set, the backreference values are automatically URL escaped.
Gumbo
thanks again for explanation!
Vittorio Vittori