Alechko Posted July 17, 2012 Share Posted July 17, 2012 Hello folks, I need a little help with rewriterules in htaccess. I have those files: product.php?id=*1* (numeric) vendor.php?name=*HP* (string) cat.php?id=*141* (numeric) I Rewrited something like that: RewriteEngine On Options +FollowSymLinks RewriteRule ^(.+)/$ vendor.php?name=$1 that it will be: domain.com/HP/ And I'm stuck.. because I don't have any clue how to Rewrite it to the final result: domain.com/HP/CatID/ProductID/ Thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/265814-help-with-htaccess-and-multipie-vars/ Share on other sites More sharing options...
JustLikeIcarus Posted July 17, 2012 Share Posted July 17, 2012 If you have 3 different scripts I would think you would want 3 different rules for example: RewriteRule ^vendor/(.+)$ vendor.php?name=$1 RewriteRule ^category/([0-9]+)$ cat.php?id=$1 RewriteRule ^product/([0-9]+)$ product.php?id=$1 Otherwise you may be better off passing the url to a php script to parse out using its regex engine. RewriteRule ^(.+)$ parse.php?url=$1 Quote Link to comment https://forums.phpfreaks.com/topic/265814-help-with-htaccess-and-multipie-vars/#findComment-1362162 Share on other sites More sharing options...
Alechko Posted July 17, 2012 Author Share Posted July 17, 2012 And if I want those 3 variables in the same time? Like this: domain.com/Vendor/CatID/ProductID without any prefix before the cat/productID. thanks for the help.. Quote Link to comment https://forums.phpfreaks.com/topic/265814-help-with-htaccess-and-multipie-vars/#findComment-1362166 Share on other sites More sharing options...
JustLikeIcarus Posted July 17, 2012 Share Posted July 17, 2012 Well the following rule would split the url by '/' and set the vars vendor/category/product RewriteRule ^(.+)/(.+)/(.+)$ script.php?vendor=$1&category=$2&product=$3 Quote Link to comment https://forums.phpfreaks.com/topic/265814-help-with-htaccess-and-multipie-vars/#findComment-1362167 Share on other sites More sharing options...
Alechko Posted July 20, 2012 Author Share Posted July 20, 2012 okey, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/265814-help-with-htaccess-and-multipie-vars/#findComment-1363007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.