我当前的网址如下所示。
http://example.com/news.php?id=25&cat=news&date=01092010&title=this-is-the-first-title
我想让它像
一样清洁我只知道.htaccess如何与其指令的基本理解一起工作的基础,我该如何实现?
编辑:我不希望显示ID。
谢谢
答案 0 :(得分:1)
RewriteRule ^([a-z]+)/([0-9]+)/([a-z-]+)$ /news.php?cat=$1&date=$2&title=$3
但请注意id
未包含在此“漂亮网址”中!因此,您必须根据$_GET['date']
和$_GET['title']
中的值,在news.php中手动查看(或直接获取新闻项)。
上述规则会将http://example.com/news/01092010/this-is-the-first-title
表单上的请求转换为http://example.com/news.php?cat=news&date=01092010&title=this-is-the-first-title
。