How to mod_rewrite based on http-header content-type
The content type is not set at request time, so far as I am aware. Thus, you would need to check if the browser is sending an Accept
header, which describes to the server what kinds of data it will accept (and display) without downloading it. Most browsers do this. They send the following header string to the server (this is obtained from Chrome):
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Therefore, you would need to check the Accept
header using a condition:
RewriteCond %{HTTP:Accept} text/html [NC]# Then, add your RewriteRules here ...
This will check to see if text/html
is contained in the Accept
header.