seo - Enabling compression in .htaccess file is causing 500 internal error

This is the code I am adding to my .htaccess file for compression and browser caching and gzip.# BEGIN WordPress<IfM

This is the code I am adding to my .htaccess file for compression and browser caching and gzip.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

When I go to the dashboard>settings>permalinks and click save changes, this code disappears and only the first block remains and the 500 internal error gets resolved. But my website is still not compressed or cached or gzipped. I need those three things to speed up the site.

This is the code I am adding to my .htaccess file for compression and browser caching and gzip.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>

# END WordPress

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

When I go to the dashboard>settings>permalinks and click save changes, this code disappears and only the first block remains and the 500 internal error gets resolved. But my website is still not compressed or cached or gzipped. I need those three things to speed up the site.

Share Improve this question asked Jul 20, 2016 at 8:28 Asem J SyedAsem J Syed 551 silver badge8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

When I go to the dashboard>settings>permalinks and click save changes, this code disappears

It sounds like WordPress is overwriting your htaccess file when you save. Thus, your changes are gone.

Perhaps set this up outside of the htaccess in the apache config? Or ask your host to do this for you. Then WP can't overwrite it :)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744996535a4605226.html

相关推荐

  • seo - Enabling compression in .htaccess file is causing 500 internal error

    This is the code I am adding to my .htaccess file for compression and browser caching and gzip.# BEGIN WordPress<IfM

    17小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信