htaccess url重写2获取值

时间:2019-05-15 07:22:49

标签: php apache .htaccess url-rewriting

我正在使用 PHP 7.2 URL重写规则。我正在建立2个链接,第一个链接是“ category.php?inventory_id = ”,第二个链接是“ show-subcategories.php?cat_id ”,但结果始终是第一个链接正在缺少代码,请帮助...

我需要URL

www.example.com/product-list-nokia-1 // category url
www.example.com/category/product-list-nokia-n72-3 // subcategory url
www.example.com/category/subcategory/product-list-nokia-n72-3 // subcategory url

当前网址

https://www.example.com/show-subcategories.php?cat_id=1
https://www.example.com/show-childcategories.php?sub_cat_id=1
https://www.example.com/search-result.php?p_id=1

此处的htaccess代码...

错误规则,请立即检查

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (\d+)$ category.php?inventory_id=$1 [L]
RewriteRule category/(\d+)$ show-subcategories.php?cat_id=$1 [L]//error part rule is not working

0 个答案:

没有答案