[ad_1]
Hi there, quick question for you…
I’m using the Rewrite API for the first time, but the problem is the URLs aren’t rewriting – they’re instead redirecting.
I’ve only played around with a pretty standard example I found on a few posts on the topic – see below:
add\_action(‘init’, ‘rewrite\_rule\_example’);
function rewrite\_rule\_example(){
add\_rewrite\_rule(‘\^post-by-slug/(.\*)/?’. ‘index.php?name=$matches\[1\]’, ‘top’);
flush\_rewrite\_rules();
}
Is there something I’m missing here? Appreciate any help!
Thanks!
[ad_2]
You have a typo:
`add_rewrite_rule(‘^post-by-slug/(.*)/?’. ‘index.php?name=$matches[1]’, ‘top’);`
should be:
`add_rewrite_rule(‘^post-by-slug/(.*)/?’, ‘index.php?name=$matches[1]’, ‘top’);`
The period for a comma. Gets you every time.