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_number=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? Thanks in advance!
You are asking about .htaccess settings for page_number only, or for whole system (cat_name, sort,...)? Can you show here your actually .htaccess file?
I don't have a .htaccess file yet! and I would like the .htaccess settings for the whole system, i.e.cat_name, sort_by, page_number
I just tried that: Options +FollowSymLinks RewriteEngine On RewriteRule ^/browse/(.+)/(.+)/(.*)$ /index.php?cat_name=$1&sort=$2&page=$3 [L] Code (markup): And I am getting a server 500 error. Any ideas? Edit: Actually it's all fine!!! Needed to enable to module on my server
OK slight problem!! When I have this in my .htaccess file: RewriteRule ^/browse/eating-out/10/(.+)/(.*)$ /index.php?cat_id=10&sort=$1&page=$2 [L] Code (markup): and go to: http://www.site.com/browse/eating-out/10/ I am getting a 404 error! Any ideas what's going wrong?
Change the rewrite rule back to how it was when shockworks wrote it. You don't need to add them manually for each category, it will do it itsself
but the thing is, I need to show the category name in the URL for SEO purposes, then the ID would be for PHP purpose. So effectively im having to specify the category name and id in the rerwrite code to prevent any confusion, yet allow the page number and sorting method to be changed. Does that make sense?
Maybe a missing slash (/). Please try this code: RewriteRule ^/browse/eating-out/10/(.*)/(.*)/$ /index.php?cat_id=10&sort=$1&page=$2 Code (markup): Make sure the URL /index.php?cat_id=10&sort=xxxx&page=xxxx exists. Error 404 means "not found".
OK I managed to get it to work such that anything in the format http://www.site.com/browse/eating-out/10/id/1/ works! 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??
Your problem: You are requiring "/" in URL: If you type site.com/browse/eating-out/10/// it is ok, isn't it? You have to define: RewriteRule ^/browse/eating-out/10/(.*)(/*)(.*)(/*)$ /index.php?cat_id=10&sort=$1&page=$3
RewriteRule ^/browse/eating-out/10/(.*)(/*)(.*)(/*)$ /index.php?cat_id=10&sort=$1&page=$3 generates a 404 error. tbh I don't follow it either.