Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#23491 closed enhancement (fixed)

Add hook to insert_with_markers() so theme/plugin authors can prevent writing to .htaccess

Reported by: alimony Owned by: wonderboymusic
Milestone: 3.7 Priority: normal
Severity: normal Version:
Component: Rewrite Rules Keywords: has-patch
Focuses: Cc:


If not using .htaccess to rewrite, but instead keeping those settings in an Apache config file, it would be nice if writing the .htaccess file could be prevented by hooking into the function that does that (e.g. returning false or something like that).

Why? If the Apache option AllowOverride is turned off (which it should be for performance reasons, if not using any .htaccess files) the file won't ever be read. But still having it around (except cluttering) can possibly confuse someone having access to the server, seeing the file and thinking it actually controls anything. Especially since most WordPress support threads on the Internet assumes that an .htaccess file is used for rewrite rules.

One solution is to keep an empty, non-writable .htaccess file, optionally having a comment in it saying it's unused, but getting rid of the file altogether would be much cleaner. Also, it can still happen that someone accidentally changes the file permission, and someone else (or the same person) saves permalink options, saving a new .htaccess file, having created the possibility of confusion once again.

Attachments (2)

23491.diff (724 bytes) - added by jeremyfelt 8 years ago.
Introduces filter flush_rules_hard
23491.2.diff (722 bytes) - added by nacin 8 years ago.

Download all attachments as: .zip

Change History (11)

8 years ago

Introduces filter flush_rules_hard

#1 @jeremyfelt
8 years ago

  • Keywords has-patch added

23491.diff introduces a filter flush_rules_hard that enables one to skip the creation of a .htaccess file or IIS file. This comes in handy not only for those managing configurations separately, but for Nginx or other web servers as well where the .htaccess file becomes just clutter.

8 years ago

#2 @nacin
8 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 3.7

My take is 23491.2.diff. Thoughts?

#3 @jeremyfelt
8 years ago

I like that that one better.

#4 @wonderboymusic
8 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 25328:

Add filter flush_rewrite_rules_hard to give devs chance to prevent writing to file when hard-flushing rewrite rules.

Props jeremyfelt, nacin.
Fixes #23491.

#5 @DrewAPicture
8 years ago

  • Keywords needs-docs added; commit removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

This filter needs a docblock per inline documentation standards

#6 @nacin
8 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 25464:

Add documentation for the new flush_rewrite_rules_hard filter. fixes #23491.

#7 @DrewAPicture
8 years ago

  • Keywords needs-docs removed

#8 @chriscct7
7 years ago

#14549 was marked as a duplicate.

#9 @DrewAPicture
7 years ago

#14549 was marked as a duplicate.

Note: See TracTickets for help on using tickets.