WordPress Development Asked by bhoqs on December 26, 2021
I am new in wordpress
There may a mapping question in my website
I hope this SEO URL is work and get Post data:
http://domain/web/d-post/M00069/TomLi
If not using SEO URL(get action), it is work!
http://domain/web/d-post?d_id=M00069&d_name=TomLi
http://domain/web/d-post/?d_id=M00069&d_name=TomLi
http://domain/web?pagename=d-post&d_id=M00069&d_name=TomLi
http://domain/web/?pagename=d-post&d_id=M00069&d_name=TomLi
In this case
http://domain/web/d-post/M00069/TomLi
but why my page will redirect to:
http://domain/web/d-post/
Should I set or change something that can make my URL work?
Thanks a lot
# RewriteEngine On RewriteBase /web/ RewriteRule ^d-post/([A-Z0-9]+)/(.*)/$ ?pagename=d-post&d_id=$1&d_name=$2 [L] #
Oh I find I should add some filter
add_filter('query_vars','d_search_1'); function d_search_1($vars) { array_push($vars, 'd_id'); return $vars; }
Answered by bhoqs on December 26, 2021
Try by this.
function myff() {
global $wp_rewrite;
if ( !isset( $wp_rewrite ) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks() )
return;
if ( is_search() && !is_admin() && strpos( $_SERVER['REQUEST_URI'], "/search/") === false && ! empty( $_GET['s'] ) ) {
wp_redirect( site_url() . "/search/" . urlencode( get_query_var( 's' ) ) );
exit;
}
}
add_action( 'template_redirect', 'myff' );
Or through .htaccess
RewriteCond %{QUERY_STRING} \?s=([^&]+) [NC]
RewriteRule ^$ /search/%1/? [NC,R,L]
Answered by Sergei on December 26, 2021
If i clearly understood you want to change permalink. you can set any type of permalink in admin menu > settings >permalinks.
Answered by Sergei on December 26, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP