【问题标题】:Clean URL's with .htaccess?使用 .htaccess 清理 URL?
【发布时间】:2011-03-18 09:23:26
【问题描述】:

我怎样才能简单地替换大写字母(我找到了,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 内部服务器错误。

请提供任何帮助/指导! :)

【问题讨论】:

    标签: .htaccess url mod-rewrite


    【解决方案1】:
    RewriteRule ^articles/(.*)$  index.php?id=$1 [NC,L]
    

    【讨论】:

    • 我已经更新了规则,我完全搞错了!不知道我之前在想什么……
    • 嗯..我似乎仍然收到错误..如果我转到 wwwmysite.com/articles/this-is-an-article-url 然后我收到 500 内部服务器错误。
    • 如果您访问 wwwmysite.com/index.php?id=this-is-an-article-url 那么这样可以吗?
    • 好的,现在我没有收到 500 Internal Server 错误,但没有加载任何内容...?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-06
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多