使用带有&的网址char和其他特殊字符

时间:2010-01-30 17:28:34

标签: url url-rewriting urlencode url-style

我正在尝试使用URLs中的特殊字符,但我在处理问题时遇到了一些麻烦,以及我为了使其正常工作所做的事情。

我看过以下网址:

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

在Last.FM上完美运作,但我怎么能这样做?

我已经this question以某种方式询问了这个问题,但部分感谢.htacess文件(.+?)中的正则表达式帖子解决了我的问题,但我仍然遇到问题网址。

如果我写了http://mysite.com/event/Dance&Jump之类的内容并在我的php页面中使用:

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

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

页面将打印出来:

//<html> printed page

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

//</html> printed page

我希望能够使用Last.FM或Wikipedia等几乎所有特殊字符

tecniques如何使用特殊字符和常用程序?

1 个答案:

答案 0 :(得分:1)

试试B flag

RewriteRule ^event/(.+?)/?$ event.php?event_name=$1 [B]