简体   繁体   中英

Wordpress add_rewrite_rule working on Apache, not on IIS

I am having the following rewrite rule :

add_action( 'init', 'custom_rewrite_rules' );
function custom_rewrite_rules() {
    add_rewrite_rule('formation(/([^/]+))?(/([^/]+))?/?','index.php?pagename=formation&formation_slug=$matches[2]&formation_id=$matches[4]','top');
    add_rewrite_tag('%formation_slug%','([^&]+)');
    add_rewrite_tag('%formation_id%','([^&]+)');
}

This works fine on my Apache server, and not on my client's IIS. I flushed the rewrite rules and the Monkeyman Rewrite Analyzer plugin tells me the redirection should work as planned.

Any suggestion of what I am missing?

Thanks a lot in advance for your help

EDIT : UP!

The problem was that IIS doesn't accept '+' character in URLs, as explained here , and that I was using urlencode() and urldecode() to generate my URLs.

The workaround I implemented was simply to replace '+' by '--'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM