I would like to produce a 404 error intentionally for some pages on my server, and I am currently working on the headers. The problem is, for the scripts that exists (and I give a 404 error in the script), the Content-Type header field shows text/html; charset=UTF-8, while for the real 404 pages the same field shows text/html; charset=iso-8859-1, which defeats my purpose. I've tried adding AddDefaultCharset UTF-8 to the main config but there's no luck. The question is, how to set the charset on these real error pages?

  • Define "I give a 404 error in the script"? Is that Apache server returning a 404? some other backend? – ezra-s Feb 14 '17 at 16:45
  • It's something like header('HTTP/1.1 404 Not Found') – lkp111138 Feb 15 '17 at 8:12
  • so it's your script making the response , make your script return the correct charset. – ezra-s Feb 15 '17 at 16:34

Figured it out: Use ErrorDocument for the desired error code (in this case 404), make it point to a script under the web root, then setting whatever I like in the ErrorDocument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.