我有以下页面:
mysite.com/news/index.php?tag=tag&name=name&id=id
我想重写一遍,以便它如下所示
mysite.com/news/tag/name-id
完整的例子就是。
foobar.com/news/apple/the-new-iphone-5-9001
此外,在我重写此URL之后,我仍然可以像往常一样提取数据:
$_GET['tag'] //would be apple
$_GET['name'] //would be the-new-iphone-5
$_GET['id'] //would be 9001
答案 0 :(得分:3)
将此添加到您的网络根目录中的.htaccess。
RewriteEngine On
RewriteBase /
RewriteRule ^news/([^/]+)/(.+?)-(\d+)/?$ /news/index.php?tag=$1&name=$2&id=$3