开发者

.htaccess rewriting $_GET variables

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 w开发者_Go百科ould 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
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜