I have a WordPress site with WooCommerce installed and Avada theme. I am trying to do a rewrite rule via functions.php file.
I want that what arrives on http://example.com/product/SKU01 has to be redirected on http://example.com/custom-file.php?prod_sku=SKU01
add_action('init', 'dcc_rewrite_tags'); function dcc_rewrite_tags() { add_rewrite_tag('%propref%', '([^&]+)'); } add_action('init', 'dcc_rewrite_rules'); function dcc_rewrite_rules() { add_rewrite_rule('^product/?$','custom-file.php?prod_sku=$matches[1]','top'); } Within a plugin (Rewrite Rule Inspector) I can see that all is working but, when I try to open the URL on the frontend, it is not working.
This is not working at all. My WooCommerce doesn't use any "product" string in its URLs, but it is not working at all. I also tried with .htaccess but I get the same behavior. Every time I call /product/sku01 I am redirected to 404 page.