rewrite rules - add_rewrite_rule redirects if value = 1

I'm currently having a small issue with add_rewrite_rule and can't seem to find any similar issues on stack ov

I'm currently having a small issue with add_rewrite_rule and can't seem to find any similar issues on stack overflow (even though there seems to be a lot).

It works fine for every URL I try:

profile/0/

profile/2/

profile/12313131/

I'm able to get the variable easy enough using $wp_query->query_vars['pid']

But if I try:

profile/1/

it always redirects to profile/

This is the only value that won't work. I can work around this if need be but wondering why this is the case? This is the first time I've had to use add_rewrite_rule and I normally just use htaccess.

Any help would be greatly appreciated.

The code I'm using is:

function profile_rewrite() {

    add_rewrite_tag('%pid%', '([0-9]+)');
    add_rewrite_rule('^profile/([0-9]+)/?', 'profile/?pid=$1', 'top');

}
add_action( 'init', 'profile_rewrite', 10, 0 );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745642386a4637770.html

相关推荐

  • rewrite rules - add_rewrite_rule redirects if value = 1

    I'm currently having a small issue with add_rewrite_rule and can't seem to find any similar issues on stack ov

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信