Html code not being read as a webpage - html

I think this is something simple,
this code isn't displaying as a web page:
http://summercpd.com/ophthalmic
Any help would be greatly appreciated :-]

Your web server is not sending the header
Content-Type: text/html
Without that, the browser doesn't know how to display the content.

The content type of the sent document is text/plain, it has to be text/html.
Add a file called .htaccess in the same folder with the following content:
AddType text/html .html .htm
The file name should then end with *.html

Related

how to prevent server I don't own from sending charset=UTF-8 in the http request

I have an old web site in French tha I want to preserve and whose html files were encoded in iso-8859-1. All html files included
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
in the <head> element, however the host of my website changed something in the configuration an now pages are sent from their server with an HTTP header including
content-type: text/html; charset=UTF-8
and unfortunately someone decided this would override the <meta> information.
Do I have to trans-code all my html files to UTF-8 or is there a faster solution?
Update
In fact the charset was added to the http header's content-type field only for html content issued by php, not for pure html files. I'll put the solution I adopted as an answer.
Your options:
Transcode the files
Persuade whomever changed the server configuration to change it again
Change servers
Run all every request through a server side script which outputs a different Content-Type header and then outputs the HTML (which accounting for cache-control headers)
Took me a while to realize the problem occurs only for .php files. The fix I chose is the following: I added the line
ini_set('default_charset', NULL);
at the beginning of every php files. A bit tedious but seems reasonable to me.

MIME type not working for SVG

I am trying to embed a .svg file into my webpage (which I am editting with Aptana). The piece of code needed is
<img src="pict.svg" width=800px/>
It works perfectly when internally ran with Aptana. But when trying in the localhost or when deploying it to internet, I only get the following icon:
Somewhere I have read it has to do with declaring MIME type, and namely it is recommended to write the following piece of code in the head:
<meta http-equiv="content-type" content="image/svg+xml">
But nothing changes. Perhaps it has to do with Aptana... for instance, one can change the text encoding without using
<meta charset="UTF-8">
which makes me think that something similar may happen with the .svg files.
Any suggestion is welcome.
If you have access to your .htaccess file, add this line of code to it and save it.
AddType image/svg+xml .svg .svgz
That should fix your problem.
EDIT: How to create a htaccess file.
Just go to the folder where your index.html or index.php file is located (you homepage), and create a new file .htaccess, and just add the code from above to it and save it.
Two things to check:
Open your browser dev tools. Go to the Net/Network tab and load the page. You should be able to see from the responses what the MIME type being returned is. Look for the "Type" column in Chrome, or in Firefox click the plus sign and look for the "Content-type" response header.
What does your SVG file look like? Standalone SVG files have some basic requirements that inlined SVGs don't. The main thing is to check that your SVG file has an xmlns in its root <svg> element.
<svg ... xmlns="http://www.w3.org/2000/svg" ... >

Force browser to download a HOSTS file

I am trying to force the Browser to download a HOSTS file to the users computer but it always opens the file in a new window. If i right-click the link and choose Save As the browser adds a .txt extension to it, NOT GOOD.
You can view my page here:
http://lovespec.bugs3.com/Host_File.html
I also have an .htaccess file on my server but I don't know what to put there to force the browser to download the file. Any help would be much appreciated.
Try this in your .htaccess
<Directory />
<IfModule mod_headers.c>
<FilesMatch "hosts">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
</IfModule>
</Directory>
Just a trick for the browser to think it's opening a non-text file.
Have you simply tried to add ? This will redirect and download it,by it self.
Let me know if that simply solution doesn't work. Working in some cases.
So here you have an showoff of my example.
Example here !

css MIME type text/html AND AddType ignored

Here is the problem, try to load a css file from a folder and get the console error: "Resource interpreted as Stylesheet but transferred with MIME type text/html". Try to fix it by adding .htaccess file (in the root/in same folder as css) with "AddType text/css .css" in it, but it is completly ignored.
How can it be fix?
(Don't know if matters but I'm in windows 8.1 and WAMP)
Appreciate any feedback.
Try this:
<FilesMatch "(\.css)$">
AddType text/css .css
Header set Content-Type text/css
</FilesMatch>
But you really shouldn't have to. text/html is normal.
Because of a security issue it is not enough to set style sheet "rel" tag type property to text/css, you should set content type in http headers(content-type:text/css), it seems you use Apache but in case another person have this problem in IIS and see this page: go to control panel -> programs and features -> turn windows features on or off -> internet information services -> world wide web services -> common http features -> static content, enable this option and restart your IIS.

Why doesn't SVG work on local HTML files?

I'm confused.
If I point by browser (Chrome or Safari on OSX) to this web site, it shows all the SVG perfectly:
http://emacsformacosx.com/
Now, if I view source on that page, copy it, and paste it into a new HTML document on my desktop, then view that with either browser, I get no SVG at all.
Why the difference?
Why does SVG work on the web site, but not in the local HTML file?
Thanks!
You renamed it to HTML, and the browser assumes html content.. while the page is text/xml ..
if you rename it to .xml and open it, you will see it just fine..
The HTTP response header information causes the browser to interpret the information as XML:
HTTP/1.1 200 OK
Date: Sun, 21 Feb 2010 02:32:02 GMT
Server: Apache/2.2.14 (Debian)
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/xml; charset=UTF-8
You see, the server that served up the page was smart enough to detect that this was an XML document, and told the browser. When you load the file from disk, your browser may not be smart enough to do this, and tend to rely on the file's extension to supply this information.
You could try inserting the following into the <head> element:
<meta http-equiv="Content-Type" content="text/xml; charset=UTF-8" />
You see what I did there? It's just a mirror of the HTTP response header that would have specified the document type and encoding.
The purpose of this tag is to make browsers think, "Hey, the server is telling me that this document is HTML, but the document is telling me it's XML. The document probably knows better than the server, so I'll trust it... ::interprets as XML::"