• Hello,

    I am working on a custom plugin and I have the following rewrite rule:

    add_rewrite_rule(
    '(.+?)/([^/]+)/([^/]+)/?$',
    'index.php?pagename=$matches[1]&state=$matches[2]&city=$matches[3]',
    'top'
    );

    It’s working on all pages but the homepage. Whenever I try to pass parameters to the homepage it automatically redirects to the root.

    For example if I type in domain.com/state/city it send me straight to domain.com and I am not able to get the parameters.

    I have tried to add the following rewrite rules with no avail

    add_rewrite_rule(
    '([^/]+)/([^/]+)/?$',
    'index.php?pagename=home&state=$matches[1]&city=$matches[2]',
    'top');
    
    add_rewrite_rule(
    '(.+?)/([^/]+)/([^/]+)/?$',
     'index.php?state=$matches[2]&city=$matches[3]',
    'top'
    );

    I’m guessing there is a built in WordPress redirect that automatically redirects anything referencing the static homepage to the root, but I’m not sure.

    Any ideas on how to get this working?

    Thanks so much!
    Jake

  • The topic ‘Rewrite Rule not working with Front Page’ is closed to new replies.