• Hello,

    I try to use add_rewrite_rule() to create a custom rewrite in my theme.

    I add the following code in my functions.php

    function custom_add_rewrite_rules() {  
    
    	add_rewrite_rule( '^test/subpage/', 'index.php?p=279', 'top' );
    
    	flush_rewrite_rules();
    }

    So when I type the following URL: http://example.com/wp/test/subpage/ it should load the page 279. But it don’t work, it still look like the home page with “page not found” in the meta title.

    Maybe it doesn’t work because my WordPress is in the subdir “wp”.

    Can someone help me?

The topic ‘custom rewrite rules’ is closed to new replies.