Title: info .htaccess
Last modified: April 5, 2021

---

# info .htaccess

 *  Resolved [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/info-htaccess/)
 * Hi, I casually found WP-Optimize tried to write my .htaccess:
 * > file_put_contents(/home/repo/www/.htaccess): failed to open stream: Permission
   > denied in /home/repo/www/wp-content/plugins/wp-optimize/includes/class-wp-optimize-
   > htaccess.php on line 135
 * Could you please tell me WHY you try to rewrite my .htaccess file? In the past
   months I was going crazy trying to figure out WHAT was causing the “reconfiguration”
   of my file, so I decided to set lower writing permissions and this morning I 
   found it was WP-Optimize, but I can’t understand why do you need to overwrite
   it.
 * The current htaccess is a very specific one: the WP original has been removed
   and there are some precious rules related to HSTS that can’t be overwritten every
   now and then.

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

 *  [Harshad](https://wordpress.org/support/users/bornforphp/)
 * (@bornforphp)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/info-htaccess/#post-14280467)
 * [@islp](https://wordpress.org/support/users/islp/) WP-Optimize edit .htaccess
   file to add following GZIP and caching rules
 *     ```
       # BEGIN WP-Optimize Gzip compression
       <IfModule mod_filter.c>
       	<IfModule mod_deflate.c>
       # Compress HTML, CSS, JavaScript, Text, XML and fonts
       		AddType application/vnd.ms-fontobject .eot
       		AddType font/ttf .ttf
       		AddType font/otf .otf
       		AddType font/x-woff .woff
       		AddType image/svg+xml .svg
   
       		AddOutputFilterByType DEFLATE application/javascript
       		AddOutputFilterByType DEFLATE application/rss+xml
       		AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
       		AddOutputFilterByType DEFLATE application/x-font
       		AddOutputFilterByType DEFLATE application/x-font-opentype
       		AddOutputFilterByType DEFLATE application/x-font-otf
       		AddOutputFilterByType DEFLATE application/x-font-truetype
       		AddOutputFilterByType DEFLATE application/x-font-ttf
       		AddOutputFilterByType DEFLATE application/x-font-woff
       		AddOutputFilterByType DEFLATE application/x-javascript
       		AddOutputFilterByType DEFLATE application/xhtml+xml
       		AddOutputFilterByType DEFLATE application/xml
       		AddOutputFilterByType DEFLATE font/opentype
       		AddOutputFilterByType DEFLATE font/otf
       		AddOutputFilterByType DEFLATE font/ttf
       		AddOutputFilterByType DEFLATE font/woff
       		AddOutputFilterByType DEFLATE image/svg+xml
       		AddOutputFilterByType DEFLATE image/x-icon
       		AddOutputFilterByType DEFLATE text/css
       		AddOutputFilterByType DEFLATE text/html
       		AddOutputFilterByType DEFLATE text/javascript
       		AddOutputFilterByType DEFLATE text/plain
       		AddOutputFilterByType DEFLATE text/xml
   
       # Remove browser bugs (only needed for really old browsers)
       		BrowserMatch ^Mozilla/4 gzip-only-text/html
       		BrowserMatch ^Mozilla/4\.0[678] no-gzip
       		BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
       		Header append Vary User-Agent
       	</IfModule>
       </IfModule>
       # END WP-Optimize Gzip compression
       # BEGIN WP-Optimize Browser Cache
       <IfModule mod_expires.c>
       	ExpiresActive On
       	ExpiresByType text/css "access 28 days"
       	ExpiresByType text/html "access 28 days"
       	ExpiresByType image/gif "access 28 days"
       	ExpiresByType image/png "access 28 days"
       	ExpiresByType image/jpg "access 28 days"
       	ExpiresByType image/jpeg "access 28 days"
       	ExpiresByType image/webp "access 28 days"
       	ExpiresByType image/x-icon "access 28 days"
       	ExpiresByType application/pdf "access 28 days"
       	ExpiresByType application/javascript "access 28 days"
       	ExpiresByType text/x-javascript "access 28 days"
       	ExpiresByType application/x-shockwave-flash "access 28 days"
       	ExpiresDefault "access 28 days"
       </IfModule>
   
       <IfModule mod_headers.c>
       	<filesMatch "\.(ico|jpe?g|png|gif|webp|swf)$">
       		Header set Cache-Control "public"
       	</filesMatch>
       	<filesMatch "\.(css)$">
       		Header set Cache-Control "public"
       	</filesMatch>
       	<filesMatch "\.(js)$">
       		Header set Cache-Control "private"
       	</filesMatch>
       	<filesMatch "\.(x?html?|php)$">
       		Header set Cache-Control "private, must-revalidate"
       	</filesMatch>
       </IfModule>
   
       #Disable ETag
       FileETag None
       # END WP-Optimize Browser Cache
       ```
   
 * If the rules are not added to .htaccess file then some features may not work 
   as expected in WP-Optimize.
 *  Thread Starter [islp](https://wordpress.org/support/users/islp/)
 * (@islp)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/info-htaccess/#post-14291738)
 * [@bornforphp](https://wordpress.org/support/users/bornforphp/):
 * well, I have my own rules for the files cache too.
    Anyway, thanks for your kind
   reply.

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

The topic ‘info .htaccess’ is closed to new replies.

 * ![](https://ps.w.org/wp-optimize/assets/icon-256x256.png?rev=1552899)
 * [WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance](https://wordpress.org/plugins/wp-optimize/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-optimize/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-optimize/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-optimize/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-optimize/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-optimize/reviews/)

## Tags

 * [htaccess](https://wordpress.org/support/topic-tag/htaccess/)

 * 2 replies
 * 2 participants
 * Last reply from: [islp](https://wordpress.org/support/users/islp/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/info-htaccess/#post-14291738)
 * Status: resolved