Permalinks - how they work

July 09, 2012 at 07:23

For a long time, I was unaware as to how the wordpress permalinks are working. After all, there is only a simple rule written into the .htaccess file, everything else happens within the script. All rules can be found in the table wp_options, just search for "rewrite_rules". Now either you directly change the rules if you know what you do or you add it in the functions.php:
add_filter('generate_rewrite_rules', 'xxx_change_rules');
function xxx_change_rules($wp_rewrite) {
    $new_rules = array(
        'marken/([a-z0-9])$'         => 'index.php?pagename=marken&buchstabe=' . $wp_rewrite->preg_index(1),
        'verkauf/page/([0-9])$' => 'index.php?pagename=verkauf&seite=' . $wp_rewrite->preg_index(1),
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;

Tags: htaccess permalinks rewrite rules

Hinterlasse einen Kommentar: