79610524

Date: 2025-05-07 12:33:58
Score: 0.5
Natty:
Report link

The solution I have found to this is:

  1. To invent a file extension for the file, so traffic-advice is renamed to traffic-advice.ta-json (an invented file extension ... traffic advice JSON)

  2. Use .htaccess to rewrite requests for traffic-advice to traffic-advice.ta-json

  3. And again in .htaccess, use AddType to set the required MIME type for ta-json files

.htaccess therefore includes:

<IfModule mod_mime.c>
AddType application/trafficadvice+json ta-json
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteRule ^\.well-known/traffic-advice$ .well-known/traffic-advice.ta-json [PT]

# continues with other RewriteRules
</IfModule>

The traffic-response file lives in .well-known, only it's renamed with my 'invented' file extension to act as the trigger for setting the MIME type.

In Chrome and Firefox I can now see in the response header:

content-type: application/trafficadvice+json
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Iain H