I have a wordpress site that I host my blog on. Recently, without any (conscious) change to the configuration I started hitting issues where the main index page was being served with a Content-Type of text/plain rather than the correct text/html - leading to visitors seeing the source code, rather than the rendered page.

I’m using the W3TC Browser Cache plugin and narrowed down the problem to this portion of .htaccess file:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{HTTP:Accept-Encoding} gzip
  RewriteRule .* - [E=W3TC_ENC:_gzip]
  RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
  RewriteRule .* - [E=W3TC_PREVIEW:_preview]
  RewriteCond %{REQUEST_METHOD} !=POST
  RewriteCond %{QUERY_STRING} =""
  RewriteCond %{REQUEST_URI} /$
  RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
  RewriteCond %{HTTP_USER_AGENT} !(W3 Total Cache/0.9.4) [NC]
  RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
  RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
# END W3TC Page Cache core

If I remove this section from the .htaccess file, that page loads fine, with the correct Content-Type. However W3TC likes to reinstate this block some time after I remove it, and the problem returns.

Read more here: WordPress incorrectly serving page with content type plain/text


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , , , ,

Wordpress related questions and answers: