admin管理员组文章数量:1334389
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
In .htaccess
# RewriteEngine On RewriteBase /web/ RewriteRule ^d-post/([A-Z0-9]+)/(.*)/$ ?pagename=d-post&d_id=$1&d_name=$2 [L] #
Without using wp & run at localhost it is work
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
In .htaccess
# RewriteEngine On RewriteBase /web/ RewriteRule ^d-post/([A-Z0-9]+)/(.*)/$ ?pagename=d-post&d_id=$1&d_name=$2 [L] #
Without using wp & run at localhost it is work
Share Improve this question edited Jul 27, 2020 at 9:47 bhoqs asked Jul 24, 2020 at 9:33 bhoqsbhoqs 12 bronze badges3 Answers
Reset to default 0If i clearly understood you want to change permalink. you can set any type of permalink in admin menu > settings >permalinks.
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]
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; }
本文标签: url rewritingWhy wordpress rewrite my custom URL
版权声明:本文标题:url rewriting - Why wordpress rewrite my custom URL? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742227193a2436542.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论