php-created rss feed has encoding errors since on new server - php

After moving a website from one webserver (Apache 1.3) to another (Apache 2.0 at domainfactory), the W3C feed validator says the feed is correct but has two problems:
Feeds should not be served with the "text/plain" media type
Your feed appears to be encoded as "ISO-8859-1", but your server is reporting "US-ASCII"
php-created rss feed
The help link didn't help.
Firefox and Chrome show the source code instead of the nice feed view (other feeds are shown correctly).
We are using php 5.3.6 to generate the feed: http://www.stuttmann-karikaturen.de/feed.rss. It's generated as a file, not on-the-fly.
We have tried adding (alternatively) the following lines to .htaccess:
AddType application/rss+xml .xml
AddType application/xml .xml
AddType text/xml;charset=iso-8859-1 .xml
No change. Any ideas?
Kwebbles answer did it for me. In case someone has a similar problem, here's the correct AddType line that worked:
AddType text/xml;charset=iso-8859-1 rss

If the extension of the resource is .rss I think the AddType directives should also use that.

Don't use .htaccess, use a PHP header to make those settings.

Related

Webpage keeps prompting to download [duplicate]

I added the following line to .htaccess:
AddType application/x-httpd-php .html .htm
When I try to load any page on the side, my browser tries to DOWNLOAD the page! What am I doing wrong?
Thanks!
Most likely; you don't have the PHP module loaded for your webserver. This means that then the server finds a application/x-httpd-php file, it passes it directly to the client instead of running it through a PHP interpretor (which would run any PHP code and output a text/html content type). Since browsers don't include PHP interpretors, they treat it as any other unknown content type, and offer to save it to disc.
HTML documents should be served to browser as text/html. Change your MIME type.
AddType text/html .html .htm
If you're trying to execute HTML files as PHP, you should change the file extension to *.phtml.
*.html - HTML content
*.php - PHP content
*.phtml - HTML content with embedded PHP scripts
If you're trying to force the PHP parser to work on these file types, you should be editing the httpd.conf file on Apache to include the application/x-httpd-php MIME type for those file extensions.

How to add an AddType to an apache server

I am currently working with the Uniform Server and I would like to learn how to apply an AddType to it, so that my custom fonts, (i.e. a .otf font), is registered when I use that font on my PHP pages. This is the message I get via my console log via Google Chrome, when I am using my custom font...
Resource interpreted as Font but transferred with MIME type
application/x-font-otf: htt://.../mfont.otf
I did some digging, and so far came up with the following line that needs to be integrated...
AddType application/x-font-otf
But I'm clueless on where to put, or how to fix issues like this. But I want to learn!
Thanks for any advice!
Insert
AddType application/x-font-otf
in
If you are using xampp
C:/xampp/htdocs/xampp/apace/conf/httpd.conf
Still Not working
AddType font/opentype
Look for a file named "httpd.conf" and put it inside that file. I have no experience on Uniform Server but since it's running Apache, putting the line inside the apache httpd.conf file should work.

Custom MIME Type for PHP File

Okay, so I have a weird one for you all today. I'm looking into creating a custom MIME type for a .php file. I've read some pro's/con's on this and it won't be for much other than some experimentation to see what can really be done. My company's initials are TTP and so we decided it'd be kinda fun to have all of our .php pages re-written to a custom .ttp extension. I've attempted my normal cPanel X route with adding it in, and I've also tried adding the change into the .htaccess file. It work's perfectly fine until I change the application type to anything php.
AddType text/html ttp // works
AddType text/x-php ttp // doesn't work
AddType application/x-php ttp // doesn't work
AddType application/x-http-php ttp // doesn't work
Some things that have come up was an issue that doing this renders the .php file and therefore makes it difficult for the browser to decide how to handle it. Any other ideas? I'm pretty sure that at the end of the day this won't be something the company will do, but they wanted to see if any experiment I could run will work.
The browser doesn't handle PHP. Content-Type doesn't matter here.
Look at your CGI or module configuration, to configure PHP to handle more than .php. For PHP as a module:
<FilesMatch \.ttp$>
SetHandler application/x-httpd-php
</FilesMatch>
Handlers are specified with AddHandler. The mod_php handler is php5-script.
And the browser never handles PHP.

HTML through PHP parser

I'm trying to hide the fact I'm using PHP on one of my site pages and I'm wanting to run it through the PHP parser (just that page not them all) so I can call it filename.html as usual. I have tried a few Apache directives I found online and have a few in my .htaccess file (hotlinks and for a 404 page).
When i use one of the scripts (in my .htacess) for the PHP purpose, the page wants to be saved/downloaded (like a vcard does) and a box shows - with no page to view. Can anyone please help. I'm new to PHP but believe a module might be needed or that it could be to do with the config of my server.
You should leave the page with a .php extension and have Apache handle the file as a normal PHP file. Then use a RewriteRule in your htaccess settings to hide the php file as follows:
RewriteEngine on
RewriteRule ^yourfile\.html$ yourfile.php
There is no real need to hide the fact that you are using PHP, but if you really want to parse PHP in html files you need to edit your Apache httpd.conf file. Open it up in a text editor and find a group of lines that looks like this:-
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
(Yours may be slightly different)
Then add
AddType text/html .html
restart Apache and php in html files will be parsed.

.htaccess causes all pages to be downloaded

I added the following line to .htaccess:
AddType application/x-httpd-php .html .htm
When I try to load any page on the side, my browser tries to DOWNLOAD the page! What am I doing wrong?
Thanks!
Most likely; you don't have the PHP module loaded for your webserver. This means that then the server finds a application/x-httpd-php file, it passes it directly to the client instead of running it through a PHP interpretor (which would run any PHP code and output a text/html content type). Since browsers don't include PHP interpretors, they treat it as any other unknown content type, and offer to save it to disc.
HTML documents should be served to browser as text/html. Change your MIME type.
AddType text/html .html .htm
If you're trying to execute HTML files as PHP, you should change the file extension to *.phtml.
*.html - HTML content
*.php - PHP content
*.phtml - HTML content with embedded PHP scripts
If you're trying to force the PHP parser to work on these file types, you should be editing the httpd.conf file on Apache to include the application/x-httpd-php MIME type for those file extensions.

Categories