Is there a way to create a single rewrite rule to handle multiple variables depending on what is present?

I was able to make this work by using a power set function and then using that array to create individual rewrite rules. add_action(‘init’, ‘ebd_custom_rewrite_rules’); function ebd_custom_rewrite_rules() { $taxonomies = array( ‘engine-work’, ‘engine-specialty’, ‘application-specialty’, ‘machining-capability’, ‘dyno-facility’, ‘shop-region’); $combinations = ebd_get_array_power_set($taxonomies); $element_size_min = 2; foreach ($combinations as $combination) { if ($element_size_min <= count($combination)) { // skip … Read more

Custom URL Rewrite Rules not working

I encountered the same issue on a client project. If you haven’t already, you’ll need to add the query variable as a public query variable otherwise using get_query_var() won’t work properly. /** * Adds the query var to public vars, making it accessible. */ add_filter(‘query_vars’, ‘query_vars’); function query_vars($public_query_vars) { $public_query_vars[] = ‘custom_route’; return $public_query_vars; } … Read more

add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico

But I want change url to https://cdn.domain.com/favicon.ico, How setting this url with rewrite rules in PHP. You can’t. That’s not how WordPress rewrite rules work. add_rewrite_rule is used for mapping pretty permalinks into the form /index.php?queryvar=value&etcetc. Most servers don’t even load WordPress to handle requests like that for assets and skip PHP/WordPress completely for performance … Read more