Title: w3tc .htaccess code
Last modified: August 31, 2016

---

# w3tc .htaccess code

 *  [Alwin](https://wordpress.org/support/users/wp-opti/)
 * (@wp-opti)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/w3tc-htaccess-code/)
 * I have added some code to my .htaccess file to protect my wp-config file. The
   code is this one:
 * <files wp-config.php>
    order allow,deny deny from all </files>
 * I have placed this code at the top of my .htaccess file. Now, normally my .htaccess
   file starts with the code from W3TC.
 * Is it a problem to place this new code above the code from W3TC? Or does my .
   htacces file always have to start with the W3TC code?
 * [https://wordpress.org/plugins/w3-total-cache/](https://wordpress.org/plugins/w3-total-cache/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Kimberly](https://wordpress.org/support/users/amiga500/)
 * (@amiga500)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/w3tc-htaccess-code/#post-7298896)
 * You can put it above and it will work just fine. For me i also include htaccess
   as another file to protect. e.g.
 *     ```
       <FilesMatch "^(wp-config\.php|\.htaccess)$">
       order allow,deny
       deny from all
       </FilesMatch>
       ```
   
 * But note that i use _FilesMatch_ and not _files_ since _FilesMatch_ is the universally
   preferred way when dealing with multiple files, even though _files_ can handle
   it too.
 * As an extra layer of security you could also pull your DB details, salts, and
   keys from the wp-config and place it in a new file in the parent directory outside
   your home dir of your domain and use a require_once() in your wp-config to it.
   Of course, also setting the permissions to it and wp-config to 600.
 * Btw, i saw your other post regarding using 400. Just a heads up, w3tc attempts
   to write the following in your wp-config.
 *     ```
       /** Enable W3 Total Cache */
       define('WP_CACHE', true); // Added by W3 Total Cache
       ```
   
 * Besides this it doesnt write anything else to it. So once that is written you
   should be able to set the file to 400. However, using 600 will make it more convenient
   to disable w3tc if you so choose in the future.
 *  Thread Starter [Alwin](https://wordpress.org/support/users/wp-opti/)
 * (@wp-opti)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/w3tc-htaccess-code/#post-7298901)
 * Thank you Kimberly!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘w3tc .htaccess code’ is closed to new replies.

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

 * 2 replies
 * 2 participants
 * Last reply from: [Alwin](https://wordpress.org/support/users/wp-opti/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/w3tc-htaccess-code/#post-7298901)
 * Status: not resolved