I need my theme to default Permalink Type to Postname. Upon activation, my theme is executing the following code:
//change permalinks to /%postname%/
global $wp_rewrite;
//Write the rule
$wp_rewrite->set_permalink_structure('/%postname%/');
//Flush the rules and tell it to write htaccess or IIS
$wp_rewrite->flush_rules();
As part of the process of activating permalinks, WordPress updates web server rewrite rules. This works fine on a *nix web server, updating the rewrite rules in .htaccess, but it doesn’t create the rewrite rules for IIS.
Ok, maybe to do with permissions on the Windows machine?
Here’s the anomaly, on Windows, when the permalink is updated from the permalink settings page, the rewrite rules are correctly set in the IIS web.config.
MY QUESTION IS, with Windows IIS, how come the settings page updates the permalink type without a problem, yet the above code doesn’t (but does on *nix)?
I will NOT write a script to manually update the rewrite rules. It should be upto the WordPress API to do this.