开发者

Help dealing with .htaccess for making my URL pretty

My current URL look like this.

http://example.com/news.php?id=25&cat=news&date=01092010&title=this-is-the-first-title

i want to make it cleaner like

http://example.com/news/01092010/this-is-the-first-title

i just know the basic of how .htaccess works wit开发者_运维知识库h the basic understanding of its directive, how do i achieve this?

Edit : i dont want the id to be displayed.

thank you


RewriteRule ^([a-z]+)/([0-9]+)/([a-z-]+)$ /news.php?cat=$1&date=$2&title=$3

But note the id is not contained in this "pretty URL"! Therefore, you must manually look this up (or you directly fetch the news item) in news.php based on the values from $_GET['date'] and $_GET['title'].

The rule above will convert a request on the form http://example.com/news/01092010/this-is-the-first-title into http://example.com/news.php?cat=news&date=01092010&title=this-is-the-first-title.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜