PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] How to change content-type but keep charset on Apache2?

 September 21, 2022     apache, apache2, content-type, header, virtualhost     No comments   

Issue

I have a Apache2 server on Ubuntu for proxy server. I want to change content-type of response to client to another but it will remove charset too.

# /etc/apache2/sites-available/000-default.conf
Header set Content-Type "text/html" "expr=%{resp:Content-Type} =~ m|text/abcdefgh|"  

With this setting, when it see the header which content-type is text/abcdefgh or text/abcdefgh; charset=utf-8 or text/abcdefgh; charset=shift_jis, it will become text/html without charset

  1. Is there any way to change part of content-type by Header set or others?
  2. Where can I find the meaning of this pattern?

Many thanks!


Solution

Did you try to use edit instead of set?

Header edit Content-Type "text/abcdefgh" "text/html"

It should just replace text/abcdefgh with text/html but leave the charset as is



Answered By - Capsule
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing