url rewriting - Issue with custom rewrite for products and permalinks

admin2025-06-04  1

Not sure if I've done something incorrectly here, but I have the following rewrite rule;

    add_rewrite_rule(
    '^product/([0-9]+)/([^/]+)/?$',
    'index.php?name=productl&id=$matches[1]',
    'top'
);

Which seems to work; so if I visit the following URL

mysite/product/23/product-description-goes-here

a page loads. However, because the wordpress permalinks are enabled, it then seems to be getting rewritten again (?) to be the post title. So the resulting URL in my address bar is

mysite/product/ 

this of course is breaking the page as the id is no longer in the URL. How can I have it maintain my original URL and not rewrite it to be the pages post title?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749050676a315935.html

最新回复(0)