Why wordpress rewrite my custom URL?

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
Why wordpress rewrite my custom URL?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

If i clearly understood you want to change permalink. you can set any type of permalink in admin menu > settings >permalinks.

Method 2

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]

Method 3

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;
}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x