Skip to content
FunnelGuard

Fix guide by FunnelsGuard

HTML served as text/plain: how to fix a wrong Content-Type

SEO-078Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

Every response from a web server carries a Content-Type header. It tells the browser what kind of file is coming, such as text/html for a web page or application/json for data. The type is called a MIME type.

This issue happens when a real HTML page is sent as text/plain. The HTML is fine, but the label is wrong. Browsers follow the label, so they may show the page as plain text with all the tags visible.

Common causes are a missing MIME mapping for a file extension, a script or PHP file that sets the header by mistake, a proxy or CDN rule that rewrites it, or a page saved with an extension the server does not map to HTML.

Why it costs you leads or sales

Visitors who land on the page see code instead of your offer. They leave. Forms, buttons and checkout links do not work because nothing is rendered.

For search, the wrong type is a risk. Google generally tries to work out content from the body, but you should not rely on that. A page labelled as plain text may be treated as a text file, not a page, so it may rank poorly, lose its snippet, or be skipped by AI assistants that fetch your page. Impact is medium because it often hits only some URLs, but those can be money pages.

Where the wrong header breaks the journey
  1. Visitor or crawler requests pageRequest arrives and returns 200
  2. Server sends Content-Type: text/plainWrong label on an HTML body
  3. Page shows raw codeNo layout, no buttons
  4. Lead form or checkoutNever reached

The page content is fine, but the label makes browsers and crawlers treat it as a text file.

What the response looks like

Broken

  • Header: Content-Type: text/plain
  • Browser shows <html> and <div> tags as text
  • Crawlers may treat the URL as a text file

Fixed

  • Header: Content-Type: text/html; charset=UTF-8
  • Browser renders the page
  • Crawlers read it as a normal web page

How to check if your site has it

The fastest check is to request only the headers of the page. Look for the content-type line.

Check the Content-Type headerbash
curl -sI https://www.example.com/your-page/ | grep -i content-type
# Good:  content-type: text/html; charset=UTF-8
# Bad:   content-type: text/plain
Other ways to check
  1. Open the page in a browser

    If you see tags like <div> and <script> as text, the type is almost certainly wrong.

  2. Use browser DevTools

    Open the Network tab, reload, click the first request (the document) and read Content-Type under Response Headers.

  3. Use Google Search Console

    Run URL Inspection on the page, then View crawled page and open the HTTP response. Check the content-type line.

  4. Test several URLs

    Check the home page, a landing page, a product page and a thank-you page. Often only one template or folder is affected.

How to fix it

First find where the header is set. Test the origin server directly if you can, then test through your CDN or proxy. If the origin is right and the public URL is wrong, the CDN or proxy is the cause.

Fix by platform
  1. Look for code that sets the header

    Search your theme and plugins for header('Content-Type or send_headers. Remove or correct any rule that sends text/plain for normal pages.

  2. Check caching and security plugins

    Disable them one at a time, clear the cache and test again with curl -I.

  3. Check the server

    If a .html file or extensionless URL is affected, fix the Apache or nginx rule shown in the Custom code tab.

Apache: serve .html as text/htmlhtaccess
AddType text/html .html .htm
AddDefaultCharset UTF-8
nginx: load standard MIME typesnginx
http {
    include       mime.types;
    default_type  application/octet-stream;
}

How to confirm it's fixed

Confirm the fix
  1. Clear caches

    Purge your CDN, server cache and any page cache plugin. Old responses may keep the wrong header.

  2. Re-run curl

    Run curl -sI on each affected URL and confirm text/html.

  3. Load the page in a private window

    Check it renders with layout, images and working buttons.

  4. Request indexing

    In Search Console, run URL Inspection, then Test live URL and Request indexing for key pages.

How to prevent it happening again

Prevention checklist
  • Keep the MIME types file or include in your server config; do not delete it during upgrades.
  • Test headers on staging after any server, CDN or proxy change.
  • Review response header rules in your CDN after every edit.
  • Add a header check on key URLs to your release checklist.
  • Avoid setting Content-Type in code unless the response really is not HTML.

How FunnelGuard handles this

FunnelGuard does not check Content-Type headers today. It is a possible future check.

What FunnelGuard does do is run your real customer journeys with a robot visitor, such as lead forms, checkouts and booking or chat buttons, and check each step. If a page shows raw code, a step that needs a button or form would likely fail to complete, so a broken journey could show up that way. That would not tell you the header was the cause.

To watch for this issue yourself, run curl -sI on your key URLs after each deploy, or use a crawler such as Screaming Frog, which lists the Content-Type of each URL. Search Console URL Inspection also shows the response header for a page.

Questions people ask

Why is my website showing HTML code instead of the page?

The server is probably sending the page with Content-Type text/plain, so the browser shows it as text. It can also happen if the file is saved with the wrong extension. Check the header with curl -I and fix the server or CMS setting.

How do I check the Content-Type header of a page?

Run curl -sI https://yoursite.com/page/ and read the content-type line. You can also open browser DevTools, go to the Network tab, click the page request and read Response Headers. A normal page should show text/html.

Will Google index a page served as text/plain?

It may not be treated as a normal web page, and results can be unreliable. Google can sometimes work out the content, but you should not depend on it. Fix the header so the page is clearly HTML.

What should the Content-Type be for an HTML page?

Use text/html; charset=UTF-8. The first part says it is HTML and the charset makes sure special characters display correctly.

How do I fix Content-Type text/plain on nginx?

Make sure the http block includes include mime.types; and that no location block sets default_type or add_header Content-Type to text/plain. Then reload nginx and test again with curl -I.

Why does only one page have the wrong Content-Type?

A rule, plugin, template or script may apply only to that URL, folder or file type. Compare the affected URL with a working one and check any redirect, rewrite or CDN rule that matches it.

Can a CDN cause the wrong Content-Type?

Yes. A response header rule or cached response can overwrite the header. Compare the origin response with the public one, fix the rule and purge the cache.

Does FunnelGuard check for the wrong Content-Type header?

No, not yet. It is a possible future check. For now, use curl -I, Search Console URL Inspection or a site crawler to check your key pages.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.