• Hi!
    I m trying to use add_rewrite_rule, but it doesn’t work. I tested many code, no success.
    So I have installed a new version of wordpress in local to test properly. Same result, no success.
    So I have installed a new version of wordpress in local to test properly. Same result, no succes. I don’t know what is the problem. I added this code in function.php of the theme:

    function welcome_rewrite_rule()
    {
        add_rewrite_rule('^ok$', 'index.php?pagename=test', 'top');
    }
    add_action('init', 'welcome_rewrite_rule');

    When I go to this url :
    https://localhost:8888/rew/index.php?pagename=test,
    it’s rewritten like this :
    https://localhost:8888/rew/?pagename=test
    but it would be :
    https://localhost:8888/rew/ok

    I installed the plugin Rewrite rules inspector, and I can see my rule is registered. But it seems that WordPress has a rule over mine :
    (.?.+?)(/[0-9]+)?/?$ index.php?pagename=$matches[1]&page=$matches[2]

    I don’t understand how to work with add_rewrite_rule.
    Please help !
    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_rewrite_rule… How to use it ?’ is closed to new replies.