#21372 closed defect (bug) (duplicate)
flush_rewrite_rules() completely overwrites .htaccess
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Rewrite Rules | Version: | |
| Severity: | major | Keywords: | reporter-feedback |
| Cc: |
Description
A call to flush_rewrite_rules(true) does a very unexpected and potentially destructive thing: it completely overwrites .htaccess.
While this probably isn't stated outright anywhere in the docs, the presence of the BEGIN/END delimiters yields a strong impression that it is safe to add directives to .htaccess outside the delimited Wordpress section.
If overwriting the whole .htaccess is by design and not a bug, then the format of generated .htaccess should be changed. Instead of the BEGIN/END comments misleading the developer into thinking that directives outside of that section will be preserved, it should contain an EXPLICIT STERN WARNING that the file is auto-generated and all changes made to it will be lost.
Change History (4)
comment:1
SergeyBiryukov
— 11 months ago
- Keywords reporter-feedback added
comment:2
SergeyBiryukov
— 10 months ago
Related/duplicate: #19900
comment:3
wonderboymusic
— 9 months ago
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #19900.
comment:4
SergeyBiryukov
— 9 months ago
- Milestone Awaiting Review deleted
I can't reproduce the complete overwrite. The rules I've added manually outside of the WordPress section are still there after flush_rewrite_rules( true ).
Could you provide the steps to reproduce the issue on a clean install?