Today, I want to realize through WordPress
Http://hcsem.com/a?h-1
Pseudo-Static is
Http://hcsem.com/a-1.html
Find a lot of information, finally fix.
Just add the following code to the functions.php file:
Add_filter (' Rewrite_rules_array ', ' my_insert_rewrite_rules '); Add_filter (' Query_vars ', ' my_insert_query_vars '); Add_action (' wp_loaded ', ' my_flush_rules ' );//Flush_rules () If our Rules is not yet includedfunctionMy_flush_rules () {$rules= Get_option (' Rewrite_rules ' ); if( !isset($rules[' A-(. *). html$ '] ) ) { Global $WP _rewrite; $WP _rewrite-Flush_rules (); }}//Adding a new rulefunctionMy_insert_rewrite_rules ($rules ){ $newrules=Array(); $newrules[' A-(. *). html$ '] = ' index.php?pagename=a&h= $matches [1] '; return $newrules+$rules;}functionMy_insert_query_vars ($vars ){ Array_push($vars, ' H '); return $vars;}
How to get H value in page-a? Copy the following code:
Echo $wp _query->query_vars[' h '];?>
Board Deng: How WordPress uses Wp_rewrite to implement custom pseudo-static, non-301 redirection.