Two small subjects, two tools in the same panel, and between them they settle complaints that look mysterious: the browser downloads a file instead of opening it, and visitors get the server’s error page instead of yours.
Why the browser downloads instead of opening
When the server sends a file, it sends a label with it saying what the thing is. That label is the MIME type, and the server works it out from the file’s extension. The browser believes the label, not the content: told that a file is of an unknown type, it does the only safe thing it knows, which is to save it to disk.
| Symptom |
What is behind it |
| The site lost all its styling |
The stylesheet is being served as plain text. The browser receives it, sees from the label that it is not CSS, and ignores it. |
| A font does not load and the text falls back to another typeface |
The font file has an extension the server does not recognise. |
| An image downloads instead of showing |
A newer format, with an extension unknown to that folder’s configuration. |
| A file that should download opens on screen |
The opposite case, and it is fixed in the same place. |
| A PDF opens on one computer and downloads on another |
That one may not be the server: browsers have their own PDF setting. Check on another computer before touching anything server side. |
Fixing it in cPanel
cPanel has a MIME Types tool. It shows two lists: the system one, which is read only and already covers nearly everything, and yours, where you add whatever is missing.
| 1 |
First confirm the current label. Open the file’s address and look at the response headers, with curl -I https://yourdomain/path/file, or in the browser’s developer tools. Without this you are guessing.
|
|
| 2 |
Look for the extension in the system list. If it is already there with the right type, this is not your problem: skip to the .htaccess warning below.
|
|
| 3 |
Add a type of your own. You write the type (for instance text/css) and the extension it applies to. You can give more than one extension at a time, separated by a space.
|
|
| 4 |
Confirm again with the same command. Then in the browser, in a private window: the old file may still be stored in yours. See clearing the cache.
|
|
A rule in .htaccess beats the tool, in that folder. If you added the type and nothing changed, there is almost certainly an AddType or ForceType line in that .htaccess, put there by you or by a plugin. The file name starts with a dot, so you have to show hidden files in File Manager to see it.
|
|
Do not invent types. A wrong label is worse than no label: a file declared as a page gets interpreted by the browser, and on a file uploaded by a visitor that is a security problem, not a convenience one.
|
Custom error pages
By default, anyone who trips over a wrong address gets the server’s page: white background, system font, no way out. A page of your own hands the visitor back to the site instead of leaving them in a dead end.
In cPanel, the Error Pages tool does this in two steps: first you pick the domain, then you edit. It has a tab with the most common codes, which are 400, 401, 403, 404 and 500, and another with every 4xx and 5xx code, in case you need one that is not on the short list.
The editor offers tags you can insert into the text, which the server fills in at the moment: the requested address, the address the visitor came from, their IP address, their browser, the server name and the code. What gets saved is a file named after the code, in that domain’s folder.
| 1 |
Start with the 404. It happens far more than the rest, and it is the one that recovers the most visits if it offers a way back.
|
|
| 2 |
Give it a way out. A link to the home page, a search box, and your contact details. A beautiful page with no exit is worth nothing.
|
|
| 3 |
Make the 500 survive on its own. If the site blew up, the error page cannot depend on the database, or on plugins, or on files that may not load. Plain text and simple styling, all inside the page itself.
|
|
| 4 |
Test it. For the 404, type an address that does not exist. For the others, confirm the file was saved and that the site still opens normally.
|
|
|
A “not found” page has to return 404. The classic mistake is to build a normal page on the site and redirect wrong addresses to it: to the visitor it looks the same, but to search engines the answer becomes “everything is fine”, and they index endless copies of that page. The cPanel tool keeps the right code, which is the reason to use it.
|
|
On WordPress, the 404 belongs to the theme. Addresses WordPress handles are answered by WordPress, and the cPanel file never gets used. It is still worth having, because it covers the addresses that do not go through WordPress, such as direct files and folders.
|
A folder with no index file is a case of its own: it either lists its contents or returns 403. That is explained, with the line that switches listings off, in seeing the site before the domain points here. And to know what each code means before designing a page for it: website errors explained and error 403 Forbidden.