#7203 closed defect (bug) (fixed)
Additional linebreak needed when writing to .htaccess
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 2.6 | Priority: | high |
Severity: | major | Version: | 2.5.1 |
Component: | General | Keywords: | htaccess has-patch |
Focuses: | Cc: |
Description
When WordPress writes to the .htaccess file when a user first saves their permalink settings, if an .htaccess file already exists and does not end with a blank line, WordPress will corrupt the .htaccess file by appending # BEGIN WORDPRESS
onto the end of the last line of the file.
Steps to reproduce:
- Either create a new blog or switch off all permalink settings in your current blog.
- Create (or edit your existing) .htaccess file so that it contains some data. Do not include a blank line (eg. a line break) at the end of the file.
- Now go to your permalink settings page and enable pretty permalinks.
- Open up your .htaccess file again and observe that WordPress has appended
# BEGIN WORDPRESS
to the end of the last line in the file, thus corrupting whatever data the line contains.
Solution: Whack a "\n" in before # BEGIN WORDPRESS
to ensure the last line in the file is left alone.
Patch coming up!
Attachments (1)
Change History (10)
#4
@
17 years ago
Won't this result in tons of whitespace? If I'm reading it right, every time you update your permalinks it'll add a line break before your WP rules.
#6
@
17 years ago
Your .htaccess isn't rewritten each time you update your permalinks as rewrite rules are handled internally by WP. It's only rewritten when you disable or enable pretty permalinks.
From testing yesterday it appears that it doesn't result in extraneous whitespace. Not sure why though, as I thought Viper was correct in saying that it would. Might need some more testing.
#7
@
17 years ago
I need to check, but there still might be code that causes rewrites whenever pages are changed, harking back to the days when all rules were in .htaccess.
#8
@
17 years ago
I need to check, but there still might be code that causes rewrites whenever pages are changed, harking back to the days when all rules were in .htaccess.
The rewrite rules are flushed when pages are published still (Going back to when Pages were individual rewrite rules inside WP), not sure about .htaccess :)
Append a "\n" to the rewrite rules marker