简体   繁体   English

使用htaccess用变量重写URL

[英]URL rewriting with variables using htaccess

I have a vendor_info.php file in that am passing two variables category ID and vendor ID like vendor_info.php?cat=1&vid=13 . 我有一个vendor_info.php文件,正在传递两个变量类别ID和供应商ID,如vendor_info.php?cat=1&vid=13 Am using this code in htaccess file for rewriting 我正在htaccess文件中使用此代码进行重写

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

but its not redirecting. 但它没有重定向。 Can anyone help me for this please? 有人可以帮我吗?

You probably want something like; 您可能想要类似的东西;

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

This will rewrite (not redirect!) http://example.com/category/184/ where category is the category id and 184 is the vendor id, to /vendor_info.php?cat=category&vid=184 这将重写(而不是重定向!) http://example.com/category/184/(其中category是类别ID,184是供应商ID)到/vendor_info.php?cat=category&vid=184

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM