where is permalink info stored in database?

In the wp_options table there is a record where option_name = "permalink_structure".

However, the true, ultimate control of url rewriting is controlled by the WP_Rewrite API which saves/caches its information in the rewrite_rules wordpress option (also found in the wp_options table).

EDIT:

Also, when editing a page/post, you can change the “permalink” for that page/post (right below where you change the title). All that is doing is merely setting the post_name field for that page’s/post’s entry in wp_posts table (aka it’s changing the “slug” for that page).

For all pages, it seems that the default rewrite rules are the following:

[(.?.+?)/page/?([0-9]{1,})/?$] => index.php?pagename=$matches[1]&paged=$matches[2]
[(.?.+?)/comment-page-([0-9]{1,})/?$] => index.php?pagename=$matches[1]&cpage=$matches[2]
[(.?.+?)(/[0-9]+)?/?$] => index.php?pagename=$matches[1]&page=$matches[2]

That list was obtained by me running this php code: echo nl2br('rules=".print_r( $wp_rewrite->rules, true) . "\n");

There does not seem to be any builtin way to edit routing for pages since the permalink structure only applies to posts.

EDIT:

More random information I”m discovering: if your permalink_structure is an empty string (which is the “default” option you can choose), then wordpress completely skips all rewriting — I’m really not sure why that’s the case, but it is.

Leave a Comment