由网友(不嗅书香)分享简介:我有以下页面: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另外经过...
我有以下页面:
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 ['标签'] //将苹果
$ _GET ['名称'] //将是全新的,与iPhone 5
$ _GET ['身份证'] //将9001
解决方案
添加这在Web根为.htaccess。
RewriteEngine叙述上
的RewriteBase /
重写规则^新闻/([^ /] +)/(+?) - ( d +)/ $ /news/index.php?tag=$1&name=$2&id=$3
I have the following page:
mysite.com/news/index.php?tag=tag&name=name&id=id
I want to rewrite this so that it goes kind of as follows
mysite.com/news/tag/name-id
A full example of this would be.
foobar.com/news/apple/the-new-iphone-5-9001
Also after I rewrite this URL will I still be able to pull data as I would normally for instance:
$_GET['tag'] //would be apple
$_GET['name'] //would be the-new-iphone-5
$_GET['id'] //would be 9001
解决方案
Add this to .htaccess in your web root.
RewriteEngine On
RewriteBase /
RewriteRule ^news/([^/]+)/(.+?)-(d+)/?$ /news/index.php?tag=$1&name=$2&id=$3
相关推荐
最新文章