开发者

.htaccess rewriting $_GET variables

开发者 https://www.devze.com 2023-03-20 12:08 出处:网络
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

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

精彩评论

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