Title: [Plugin: WP Super Cache] wp-content/cache/.htaccess file went missing
Last modified: August 19, 2016

---

# [Plugin: WP Super Cache] wp-content/cache/.htaccess file went missing

 *  [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/)
 * We’ve been using WP Super Cache for several months without a problem.
 * Tonight, our homepage was downloading as a .gz file, instead of displaying properly.
   I tracked it down to a missing wp-content/cache/.htaccess file.
 * Putting the file back in place solved it.
 * I am not sure how this file went missing. From what I can tell, I do not see 
   any unauthorized accesses to the server.
 * Does anyone have any ideas how this file could have gotten deleted?
 * Thanks.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/page/2/?output_format=md)

 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716124)
 * I recently installed Role Scoper plugin. I noticed in its source that it has 
   several mentions of “htacces” but I assume this means the main WP htaccess file
   and not this one in the cache.
 * (Our main htaccess file is untouched)
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716126)
 * There is definitely a connection to Role Scoper. I just saved some options in
   Role Scoper and it wiped out the contents of wp-content/cache/, including the.
   htaccess file.
 * The htaccess file was owned by root, with 644 permissions, so it’s surprising
   that it got wiped out.
 * Also, my supercache directory was wiped out too.
 * It seems that Role Scoper is quite aggressive in deleting files in wp-content/
   cache.
 * Still looking for advice.
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716133)
 * The offending function seems to be:
 * rm_cache_dir
 * which is found in:
 * wp-content/plugins/role-scoper/hardway/cache-persistent.php
 * using Role Scoper 1.3.RC2.
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716249)
 * I’m sorry Role Scoper misbehaved in that way; thanks for reporting. You can correct
   it by editing function rm_cache_dir (in plugins/role-scoper/hardway/cache-persistent.
   php) as follows:
 * **add:**
 *     ```
       if ( ! $group )
          return;
       ```
   
 * to the top of the function. I’ll revise the RC version with this or an equivalent
   fix soon.
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716252)
 * Thanks kevinB!
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716259)
 * Actually, here’s a further tweak to that fix:
 * **
    change:
   
    `$group_dir = ( $group ) ? $this->get_group_dir($group) : '';`
 * **to:**
 *     ```
       $group_dir = ( $group ) ? $this->get_group_dir($group) : '';
   
       if ( ! $group_dir )
       	return;
       ```
   
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716261)
 * Thinking on this further, I’m not sure that code change will clear your error.
   Let me know.
 * How can you tell function rm_cache_dir was the culprit?
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716262)
 * Are you running multisite?
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716265)
 * Yes, I am running multisite.
 * I’m not positive rm_cache_dir is the culprit. But, it was the function I found
   that seemed like it would be the one.
 * I will try to test a bit later.
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716267)
 * [edited] I think you’re right. Multisite may be a factor here, because the cache
   storage path is different (stored right in the cache root) for group-related 
   cache data if you have the “share groups site-wide” option enabled.
 * If the above fix does not clear your symptoms, here is a further trap:
 * **change:**
 *     ```
       if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
       	$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
       else if (@ is_file($dir . DIRECTORY_SEPARATOR . $file)) {
       	if ( file_exists($dir . DIRECTORY_SEPARATOR . $file) ) {
       		if ( !@ unlink($dir . DIRECTORY_SEPARATOR . $file)) {
       			$errors++;
       		}
       	}
       }
       ```
   
 * **to:**
 *     ```
       if ( @ is_dir( $dir . DIRECTORY_SEPARATOR . $file ) )
       	$stack[] = $dir . DIRECTORY_SEPARATOR . $file;
       elseif ( $dir && ( $dir != rtrim( $this->cache_dir, DIRECTORY_SEPARATOR ) ) ) {
       	if ( @ is_file( $dir . DIRECTORY_SEPARATOR . $file ) ) {
       		if ( file_exists( $dir . DIRECTORY_SEPARATOR . $file ) ) {
       			if ( ! @ unlink( $dir . DIRECTORY_SEPARATOR . $file ) ) {
       				$errors++;
       			}
       		}
       	}
       }
       ```
   
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716274)
 * I reproduced this error on a multisite installation. The initial patches **if(!
   $groups )** and **if ( ! $group_dir )** are **not valid** because they prevent
   proper flushing of the RS cache.
 * However, the larger code block change above does prevent the unwanted deletions.
   I will include it (with some optimization) in 1.2.9.RC3 and 1.3.RC3
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716293)
 * Thanks. I tried 1.3RC3. The cache flushing routine safely avoids the .htaccess
   file, so that seems fine now.
 * However, the routine simply deletes the WP Super Cache directories (blogs and
   supercache) (among others).
 * Might it be better to call the cache flushing routines available in WP Super 
   Cache? Deleting those directories seems rather drastic.
 *  [jittipat](https://wordpress.org/support/users/jittipat/)
 * (@jittipat)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716294)
 * Thanks.
    [](http://www.touchwebdesign.net)
 *  [Kevin Behrens](https://wordpress.org/support/users/kevinb/)
 * (@kevinb)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716300)
 * Alright, here’s a better fix – moving the entire RS cache to a subfolder. I never
   meant to delete other plugins’ wp-cache content, and this will prevent it:
    - all other patches listed here can be skipped or reverted
    - edit function WP_Persistent_Object_Cache in **role-scoper/hardway/cache-persistent.
      php** as follows:
 * Add the following code above the existing CACHE_EXPIRATION_TIME line :
 *     ```
       $this->cache_dir = $this->cache_dir . 'rs/';
   
       if ( ! file_exists( $this->cache_dir ) ) {
       	if ( @ mkdir( $this->cache_dir ) ) {
       	   $stat = stat(WP_CONTENT_DIR);
       	   $dir_perms = $stat['mode'] & 0007777;
       	   @ chmod( $this->cache_dir, $dir_perms );
               } else
       	   $this->cache_enabled = false;
       }
       ```
   
 *  Thread Starter [Bill Dennen](https://wordpress.org/support/users/xyzzy/)
 * (@xyzzy)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/#post-1716315)
 * Thank you. This approach makes a lot more sense.

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/page/2/?output_format=md)

The topic ‘[Plugin: WP Super Cache] wp-content/cache/.htaccess file went missing’
is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 21 replies
 * 5 participants
 * Last reply from: [royoel](https://wordpress.org/support/users/royoel/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-wp-super-cache-wp-contentcachehtaccess-file-went-missing/page/2/#post-1716424)
 * Status: not resolved