Skip to content

Commit

Permalink
Closes #3113 Stop removing empty lines in the .htaccess (PR #3599)
Browse files Browse the repository at this point in the history
  • Loading branch information
iCaspar authored Feb 23, 2021
1 parent 35c1cd1 commit 4290c82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
13 changes: 0 additions & 13 deletions inc/functions/htaccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ function flush_rocket_htaccess( $remove_rules = false ) { // phpcs:ignore WordPr
* Filters disabling of WP Rocket htaccess rules
*
* @since 3.2.5
* @author Remy Perona
*
* @param bool $disable True to disable, false otherwise.
*/
Expand Down Expand Up @@ -56,18 +55,6 @@ function flush_rocket_htaccess( $remove_rules = false ) { // phpcs:ignore WordPr
$ftmp = get_rocket_htaccess_marker() . PHP_EOL . $ftmp;
}

/**
* Determine if empty lines should be removed in the .htaccess file.
*
* @since 2.10.7
* @author Remy Perona
*
* @param boolean $remove_empty_lines True to remove, false otherwise.
*/
if ( apply_filters( 'rocket_remove_empty_lines', true ) ) {
$ftmp = preg_replace( "/\n+/", "\n", $ftmp );
}

// Make sure the WP rules are still there.
if ( $has_wp_rules && ! rocket_has_wp_htaccess_rules( $ftmp ) ) {
return false;
Expand Down
5 changes: 5 additions & 0 deletions tests/Fixtures/content/htaccessContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<IfModule mod_mime.c>
AddCharset UTF-8 .atom .css .js .json .rss .vtt .xml
</IfModule>
# FileETag None is not enough for every server.
<IfModule mod_headers.c>
Header unset ETag
Expand All @@ -18,6 +19,7 @@
HTACCESS;

$fileETag = <<<HTACCESS
# Since we’re sending far-future expires, we don’t need ETags for static content.
# developer.yahoo.com/performance/rules.html#etags
FileETag None
Expand All @@ -35,13 +37,15 @@
</FilesMatch>
</IfModule>
</IfModule>
# Allow access to web fonts from all domains.
<FilesMatch "\.(eot|otf|tt[cf]|woff2?)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
HTACCESS;

$mod_alias = <<<HTACCESS
Expand Down Expand Up @@ -179,6 +183,7 @@

$end = <<<HTACCESS
# END WP Rocket
# Random
# add a trailing slash to /wp-admin# BEGIN WordPress
Expand Down

0 comments on commit 4290c82

Please sign in to comment.