0

I am trying this code from codex wordpress site

function custom_rewrite_basic() {
    add_rewrite_rule('^leaf/([0-9]+)/?', 'index.php?page_id=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_basic');

How must by .htaccess file must be configured for above code to make sense? If I put the basic wordpress .htaccess configuration file then I get redirected to same page.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

1 Answer 1

1

after adding a new rule, you have to flush the rewrite-rules in order to use them

that can be done with the "flush_rewrite_rules" function http://codex.wordpress.org/Function_Reference/flush_rewrite_rules

or it can be done in going in the Administration Screens -> Settings -> Permalink and just saving without changing something on this screen

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.