Skip to content
seo

Wordpress软件知识:伪静态设置页面前缀为page并以.html结尾

Wordpress软件知识:伪静态设置页面前缀为page并以.html结尾
//页面增加前缀 page 并以.html 结尾
add_action( 'init', 'custom_page_rules' );
function custom_page_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%.html';
}

add_filter('redirect_canonical', 'cancel_redirect_canonical');
function cancel_redirect_canonical($redirect_url)
{
if( is_page()) return false;
return $redirect_url;
}