WordPress permalinks are not nearly as flexible as I would like them to be. It offers the ability to easily change the Post permalink structure, as well as the category and tag structure, but that’s where it ends.
You have the option of using a plugin like Custom Permalinks, if you want the ability to quickly change the permalink of any term (Tag, Category, Page, etc).
However, WordPress doesn’t offer the ability to change the Page permalink structure.
After reading hundreds of posts, support threads, and articles about $wp_rewrite, I finally developed the code that worked.
The Code
By default, WordPress uses this as the Page permalink structure: /%pagename%
But let’s say you wanted to make it /page/%pagename%/ or /%pagename%.html or something of that variation.
In this example, we will change the permalink structure to be something like this: /page/credits.html (credits being the page slug)
Put this code in your functions.php file.
add_action( 'init', 'custom_page_rules' );
function custom_page_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
}
If you want to change it to be just /credits.html, you could use something like '%pagename%.html' and so on, and so on.
The few lines of code should be flexible enough to tweak and make your own.
If you have any feedback or questions about, would be happy to hear about it in the comments.



Jonathan Dingman is a passionate blogger who loves writing about WordPress news, reporting on events, theme releases, awesome plugins, and more. He started using WordPress in 2004 and ran the first WordCamp NYC in 2008.
Hi, this is super useful, but there is one thing that bothers me. If I set rewrite rule to be /%postname%/, the generated page link is /page/credits.html/, the trailing slash in the end is automatically added by WordPress unless I change the permalink to be /%postname.
Do you know how I can remove the trailing slash without changing the permalink format?
Thanks in advance.
I spent a lot of time trying to figure that out, but unfortunately, WordPress over-rides any permalink structure with the existing trailing slash or lack of trailing slash, that’s in your Custom Permalinks.
If you want to have just /page/%postname, then you do need to set it to /%postname% without the trailing slash.
If I find a way to circumvent this, I’ll post about it.
Hi, thank you for your reply. Fortunately, I did find something useful regarding this issue, please check the post here http://betterwp.net/wordpress-tips/remove-trailing-slash-for-permalinks-with-extensions/
It turns out that the canonical redirection function is what caused this issue and we can cancel it via the “redirect_canonical” filter by returning false. I think adding this snippet will make your method perfect!
Good find! I’ll do some more testing next week and see about adding it to the snippet. Thanks Sola!
I’m glad you will see to it, I love your code a lot! Looking forward to your new posts!