使用.htaccess清理网址?

时间:2011-03-18 09:23:26

标签: .htaccess url mod-rewrite

我怎样才能简单地替换大写字母(我发现它, strtolower()),符号和空格,而不是这样做?

$url = str_replace( " ", "-", "$title");
$url1 = str_replace( "!", "", "$url");
$url2 = str_replace( "?", "", "$url1");
$url3 = str_replace( ",", "", "$url2");
$url4 = str_replace( ":", "", "$url3");
$url5 = str_replace( "'", "", "$url4");
$url6 = str_replace( ".", "", "$url5");

其次,如何使用.htaccess通过http://www.mysite.com/index.php?id=The-house-from-Up访问此网址http://www.mysite.com/articles/The-house-from-Up?目前我刚收到500内部服务器错误。

请帮助/指导! :)

1 个答案:

答案 0 :(得分:0)

RewriteRule ^articles/(.*)$  index.php?id=$1 [NC,L]