0

Please check and explain why this wordpress rewrite rule isn't still working.

function myplugin_rewrite_rule() {
    add_rewrite_rule( '^music/record-year/([^/]*)/?', 'music/?record_year=$matches[1]','top' );
}
add_action('init', 'myplugin_rewrite_rule', 10, 0);


I wanted if music/?record_year=2019 is visited, it should be music/record-year/2019 instead

2
  • If you visit music/record-year/2019 does it work as expected? music/?record_year=2019 redirecting to music/record-year/2019 is a redirect and has nothing to do (directly) with rewrite rules. Same goes for changing any links. Rewrite URLs make the URL work, but redirecting and links need to be handled separately. Jan 27 at 11:58
  • The URL isn't working as expected, Its showing 404 error Jan 27 at 12:07

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.