使用htaccess用变量重写URL


URL rewriting with variables using htaccess

我有一个vendor_info.php文件,其中传递两个变量类别ID和供应商ID,如vendor_info.php?cat=1&vid=13。我在htaccess文件中使用此代码重写

RewriteRule ^category/(.*)/(.*)-(.*)$ vendor_info.php?cat=$1&vid=$3

但不是重定向。有人能帮我一下吗?

您可能想要像;

RewriteRule ^([^/]*)/([^/]*)/$ /vendor_info.php?cat=$1&vid=$2 [L]

这将重写(不是重定向!)http://example.com/category/184/,其中类别是类别id, 184是供应商id,到/vendor_info.php?cat=category&vid=184