asgsoft Posted March 26, 2010 Share Posted March 26, 2010 Hey Everyone! I am trying to figure out this problem and I can't seem to find much in terms of resources online! So I have set up a pagination system which produces URL's like this: http://www.sitename.com/index.php?cat=cat_name&sort=sort_by&page=page_number However, I want them to look like this: http://www.sitename.com/browse/cat_name/sort_by/page_number Is there a way I can do that via the .htaccess? At the moment, for each category, I am using something like this: RewriteRule ^browse/eating-out/9/(.+)/(.*)/$ browse_coupons.php?cat=9&sort=$1&page=$2 That way, I have the category name in the URL, but also the id which I use to look stuff up with in the table. This is working OK so far, however.. what if it's something like: http://www.site.com/browse/eating-out/10/id/1 or http://www.site.com/browse/eating-out/10/id that just causes a 404... Is there anyway to make it such that the variables are not compulsory?? Quote Link to comment https://forums.phpfreaks.com/topic/196644-php-pagination-with-mysql-htaccess/ Share on other sites More sharing options...
cags Posted March 26, 2010 Share Posted March 26, 2010 Placing a question mark after a capture group should make it optional, but obviously bare in mind if it isn't the last one this will cause problems. Quote Link to comment https://forums.phpfreaks.com/topic/196644-php-pagination-with-mysql-htaccess/#findComment-1032535 Share on other sites More sharing options...
asgsoft Posted March 27, 2010 Author Share Posted March 27, 2010 What do you mean? So something like this: RewriteRule ^browse/eating-out/10/(.+)$/(.*)$/$ browse_coupons1.php?cat_id=10&sort=$1&page=$2 Quote Link to comment https://forums.phpfreaks.com/topic/196644-php-pagination-with-mysql-htaccess/#findComment-1032667 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.