.htaccess重写不同动态页面的url,如category.php、subcategory.hp或product.p


.htacess rewrite url for different dynamic pages like category.php or subcategory.php or product.php

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

例如:

http://example.com/category.php?cat=$category

在.htaces url中,我想要这样example.com/category/

example.com/subCategory.php?cat=$category&subCat=$subCategory在.htaces url中,我想要这样example.com/category/subcategory/

example.com/product.php?product=$product在.htaces url中,我想要这样example.com/product/

乙醇提前

使用重写引擎和重写规则可以很容易地实现这一点。

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

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