Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Header Content-type to static pages which doesn't have extensions?

I have a XML page www.example.com/page, but my server outputs it as text/plain as it doesn't have any extension.

So I want to add XML Header via .htaccess to all the files which doesn't have extension with a condition that the file exists. As if file doesn't exist, program is executed from database and it decides what header to output, so I don't want to break that part by forcibly changing header.

like image 601
Atul Gupta Avatar asked Nov 27 '25 09:11

Atul Gupta


2 Answers

Add a DefaultType text/xml (or whatever type you're using for your XML) to your .htaccess.

like image 148
Laurence Gonsalves Avatar answered Nov 29 '25 01:11

Laurence Gonsalves


Other command you can put in your .htaccess (but it will force all files to have this content-type):

ForceType text/xml

http://httpd.apache.org/docs/1.3/mod/mod_mime.html#forcetype

like image 35
Kamil Dziedzic Avatar answered Nov 29 '25 00:11

Kamil Dziedzic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!