0

I have an issue with redirect originally my URL like this

/tips/carrieretips/page/4

but when I add string/page/4` in URL is still OK

Like this

/tips/carrieretips/page/4/string/page/4/string/page/4/string/page/4

I don't know what cause it, I want when to add string/page/4 it's supposed to be 404

tips are base. carrieretips is category

Here my rules

/*custom rules*/

add_action( 'rewrite_rules_array', 'rewrite_rules' ); function rewrite_rules( $rules ) {

$new_rules = array(
    'tips/(.+?)/(?:/([0-9]+))?/?$' => 'category_name=$matches[1]&paged=$matches[2]',
    'tips/(tag)/(.+?)/(page)/(.+?)(?:/([0-9]+))?/?$'=>'post_type=post&post_tag=$matches[2]&paged=$matches[4]',
    'tips/(tag)/(.+?)(?:/([0-9]+))?/?$'=>'post_type=post&post_tag=$matches[2]',
    '(tips)/(.+?)/(page)/(.+?)(?:/([0-9]+))?/?$' =>'category_name=$matches[2]&paged=$matches[4]',
    '(tips)/(page)/(.+?)(?:/([0-9]+))?/?$'=>'pagename=$matches[1]&paged=$matches[3]',
    '(tips)/(.+?)/(.+?)(?:/([0-9]+))?/?$'=>'post_type=post&name=$matches[3]',
    


);
return $new_rules + $rules;

}

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.