[wp-hackers] Prevent Writing to .htaccess
Otto
otto at ottodestruct.com
Thu Aug 5 04:41:23 UTC 2010
No, that'll cause the index.php prefix to be added on an Apache server.
Short version is that you can't do it. Not with the current code. You
could include some code to try to change the permissions to make
htaccess not writable, but that's it.
If you have custom rules that are getting messed with, just put them
outside the #BEGIN and #END markers. Those won't get altered.
-Otto
On Wed, Aug 4, 2010 at 10:45 PM, Eric Mann <eric at eamann.com> wrote:
> One possibility (a very hacky possibility) would be to spoof the return
> value of got_mod_rewrite(). This function is used as a Boolean flag before
> the .htaccess file is written. If it's True (if Apache has mod_rewrite
> enabled) then the .htaccess file is written. If it's False, then it's not.
>
> The beauty is that there's a filter applied in the function. So this filter
> would basically disable .htaccess from being overwritten.
>
> function disable_flush($got_rewrite) {
> return false;
> }
> add_filter('got_rewrite', 'disable_flush');
>
> Though since I haven't poked around too deeply into this, I'm not sure if
> this will impact anything else (i.e. actual permalink behavior) ... so I
> make no guarantees :-)
>
> ~Eric
>
> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com
> [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of John Sessford
> Sent: Wednesday, August 04, 2010 8:20 PM
> To: wp-hackers at lists.automattic.com
> Subject: [wp-hackers] Prevent Writing to .htaccess
>
> Hi,
>
> I've encountered a road-block with .htaccess / Rewrite Rules. Hoping someone
> here can assist.
>
> Two issues:
>
> 1. .htaccess is flushed whenever '/wp-admin/options-permalink.php' is
> loaded. It strikes me as strange that this would execute prior to action
> from the user.
>
> 2. I require a method to prevent .htaccess from being flushed even when
> "Save Changes" is clicked. I don't see a viable hook anywhere that can
> control whether or not to write .htaccess. In my case the Rewrite Rules
> should still be written to the database though. Making .htaccess read-only
> is one method, but one can't always rely on users to do this.
>
> Thoughts?
>
> Thanks in advance,
> John Sessford
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list