cedaro / satispress

Expose installed WordPress plugins and themes as Composer packages.
508 stars 51 forks source link

Overwriting Existing .htaccess Rules #84

Closed leepeterson closed 5 years ago

leepeterson commented 5 years ago

When the "pretty permalinks" option is enabled, SatisPress overwrites the typical Apache rewrite rules for WordPress in .htaccess, adding RewriteRule ^satispress/packages.json$ /index.php?satispress_route=composer [QSA,L].

I understand why this happens, and it's a nice convenience for sure.

However, if that block of rules has been modified in any way, those modifications are lost without warning.

To provide an understanding of why this is an issue for us, we always modify that block in a way that works and ensures WordPress will not overwrite it later by simply keeping the changes in between # BEGIN WordPress and # END WordPress. It also makes for a much cleaner, smaller .htaccess file.

bradyvercher commented 5 years ago

SatisPress shouldn't overwrite the typical Apache rewrite rules. All it does is [register an external rewrite rule]()https://github.com/cedaro/satispress/blob/be16e113db75613b5f20fbf4a9c157e4f83d2cbc/src/Provider/RewriteRules.php#L81-L84 using the Rewrite API. Then when WordPress writes to the .htaccess file, it includes that rule.

Anything between the # BEGIN WordPress and # END WordPress markers can be changed by WordPress, so if you're making manual modifications to those rules, they can be overwritten at any time. Custom rules should either be registered with the Rewrite API or made outside of those markers.

Does that help, or did I misunderstand how/where you're registering your custom rules?

bradyvercher commented 5 years ago

@leepeterson Were you able to look into this further or is there anything else I can help with?

leepeterson commented 5 years ago

Apologies for the late response.

I see that I failed to provide a solution. All I was getting at is that it’d be good to mention that this will occur.

Just caught me by surprise :)