Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am setting up my first site on my OSX, this is just for use on my machine so I can trial html fragments. When I open my local site and select any HTML file, it comes back as text. My test HTML file is as follows:

<html>
  <head>
  </head>
<body>
    <a>Hello World</a>
</body>
</html>

It is displayed as the actual text rather than the interpretedx text. The actual HTML returned is:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1038.36">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Courier}
  </style>

</head>
<body>
<p class="p1">&lt;html&gt;</p>
<p class="p1"><span class="Apple-converted-space">  </span>&lt;head&gt;</p>
<p class="p1"><span class="Apple-converted-space">  </span>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;</p>
<p class="p1"><span class="Apple-converted-space">  </span>&lt;/head&gt;</p>
<p class="p1">&lt;body&gt;</p>
<p class="p1"><span class="Apple-converted-space">    </span>&lt;a&gt;Hello World&lt;/a&gt;</p>

<p class="p1">&lt;/body&gt;</p>
<p class="p1">&lt;/html&gt;</p>
</body>
</html>

My apache config for my site is:

<VirtualHost *:80>
   ServerAdmin x@x.net.au
   DocumentRoot "/Users/X/web_dump/"
   ServerName web_dump
   ErrorLog /usr/local/logs/web_dump.log
   CustomLog /usr/local/logs/web_dump.log common
   AddType text/html .html
</VirtualHost>

<Directory "/Users/X/web_dump/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    AddType text/html .html
</Directory>

And firebug indicates that the page returned is of text/html format:

Date: Wed, 30 Nov 2011 20:10:26 GMT
Server: Apache/2.2.20 (Unix) mod_ssl/2.2.20 OpenSSL/0.9.8r DAV/2
Last-Modified: Wed, 30 Nov 2011 20:10:10 GMT
Etag: "a833cc-3ec-4b2f952a52c80"
Accept-Ranges: bytes
Content-Length: 1004
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

So my really dumb question is: how do I return my HTML file as a HTML file?

BTW: my Apache system is working well for the other applications that I am working on.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Your text editor (TextEdit? "Cocoa HTML Writer" seems generic enough that it might be something else) figured that you wanted to modify and HTML file's content without seeing the underlying code. Thus, all of the HTML that you entered, it escaped, thinking that was the intended content.

Edit it with something that's not trying to hide the underlying HTML from you.

share|improve this answer
    
Yep. I feel dumb. TextEdit did some magic I did not expect. Back to vi for me. –  dave Nov 30 '11 at 21:05
add comment

The problem is not in the web server but in the way you are editing the html file: you are using TextEdit, editing in Rich Text mode and saving as html.

Instead, you should select the menu option Format->Make Plain Text and save as a plain text file with the html extension.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.