[英].htaccess rewriting $_GET variables
我有以下頁面:
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
將此添加到 web 根目錄中的 .htaccess 中。
RewriteEngine On
RewriteBase /
RewriteRule ^news/([^/]+)/(.+?)-(\d+)/?$ /news/index.php?tag=$1&name=$2&id=$3
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.