.htacess重写不同动态页面的url,如category.php或subcategory.php或product.php

.htacess重写不同动态页面的url,如category.php或subcategory.php或product.php,php,.htaccess,Php,.htaccess,嗨,我想知道如何重写不同页面的url 例如: $category 在.htacces url中,我希望这样 example.com/category/ example.com/subCategory.php?cat=$category&subCat=$subCategory 在.htacces url中,我希望这样 example.com/category/subcategory/ example.com/product.php?product=$product 在.htacces url中,我

嗨,我想知道如何重写不同页面的url

例如:

$category

在.htacces url中,我希望这样 example.com/category/

example.com/subCategory.php?cat=$category&subCat=$subCategory 在.htacces url中,我希望这样 example.com/category/subcategory/

example.com/product.php?product=$product 在.htacces url中,我希望这样 example.com/product/


thanx提前

使用重写引擎和重写规则,您可以非常轻松地实现这一点

RewriteEngine on
RewriteRule ^/category/([a-zA-Z0-9-]*)/?$ /category.php?cat=$1

现在,只需将相同的逻辑应用于其他场景。

example.com/category.php?category=agricultre我想这样做hhtp://example.com/agriculture 当我点击这个链接example.com/agriculture时,我通过$\u get['category']获得值在category.php上,请帮助我,我对htacessexample.com/category.php?category=agricultre感到困惑,我想这样做hhtp://example.com/agriculture 当我点击这个链接example.com/agriculture时,我通过category.php上的$_get['category']获得了这个值