Rewriting where all parameters are in the query string and requesting index.php should result in no visible rewrite. The original URL remains with 200 status, but the query vars are all applied.
'brand/abc/([^/]+?)/?$' => 'index.php?product-category=$matches[1]&filtering=1&filter_product_brand=69',
I’m not sure if “product-category” is the right query var. If not, use the proper one and all should work.
@bcworkz I think I understand, but how do I figure out what the technical url is of the page that is shown as: /product-category/zonnepanelen/?filtering=1&filter_product_brand=69
Because that is the url that is shown if I go to the category and then filter on brand.
-
This reply was modified 4 years, 1 month ago by
ikwilhet.
Isn’t the goal for it to be brand/abc/zonnepanelen/ ? With the correct rewrite rule, WP will process it correctly, but links to the page that appear on the site will not use that structure on their own. You need to use the “term_link” filter or similar to alter the default structure to the one compatible with the rewrite rule.
Aren’t there other brands that need to be rewritten besides “abc”? Is there an URL parameter that’ll filter on “abc” instead of 69? We could rewrite whatever comes after /brand/ to such an URL parameter. If one does not exist, it might be worth creating one. Then we could do something like
'brand/([^/]+?)/([^/]+?)/?$' => 'index.php?product-category=$matches[2]&filtering=1&cust_filter_brand=$matches[1]',
That function does not work.
Ie.
brand/abc/solarpanels/
needs to use the content of
product-category/solarpanels/?filtering=1&filter_product_brand=69
I will add more links to the array
brand/def/invertors
etc. etc.
But the function doesnt work, redirects to the homepage. Where can I find the underlying url of product-category/solarpanels/?filtering=1&filter_product_brand=69
You are sayin that the content of that page can also be found with index.php with some querystrings?
is product-category a valid querystring then, is there a reference for this.
I think I understand what you want to do, but I don’t know how to find the proper URL structure to use the content from.
It’s likely “product-category” is not the right query string var. I used it as an example, but I’m not familiar enough with your ecommerce system. The ecommerce plugin ought to have it documented. As a guess, try “product-cat” instead. If you use WooCommerce I think that’s the right query var.
I’m not sure what you mean by underlying URL, but here’s an idea: switch your permalink settings to “plain” (make note of what it is now so it can be easily restored). The find a link to one the taxonomy’s terms. This will force the term to be passed as a query string var. Maybe this is what you mean by underlying URL? The links do not specify an actual file because the default index.php is the intended recipient of the request.
When you rewrite to the /product-category/ route, where ever the request ends up is not the normal rewrite destination, so you naturally get a 302 status response. The normal rewrite destination is index.php, so there’s no 302 status involved.