# browsers show code instead of web content



## kondziq (Sep 4, 2010)

Hi all, 

As in the subject - when i try to go to my website it shows source code and not the content. 
I did some testing and seems like when you type in 192.168.1.1 to the browser it will show code, but if you will give any html file after ip it will show content (i.e. 192.168.1.1/index.html or 192.168.1.1/test/test.htm will both work).
I suspect I forgot to compile something basic to my apache, but no idea what it might be. Any hints? 

Thanks in advance, 
K.


----------



## DutchDaemon (Sep 4, 2010)

[cmd=]grep DirectoryIndex httpd.conf[/cmd]. Is this directive set?


----------



## kondziq (Sep 4, 2010)

```
# DirectoryIndex: sets the file that Apache will serve if a directory
    DirectoryIndex index.html
```

Would you expect anything else here?


----------



## DutchDaemon (Sep 4, 2010)

Only if you're also serving e.g. PHP pages. Check your httpd-error.log as well.


----------



## kondziq (Sep 4, 2010)

There is nothing on the website but 1 link to a test webpage. No php, nothing. 
http-error.log indeed shows lots of errors. Most common lines are: 


```
[Sat Sep 04 15:21:25 2010] [error] [client 192.168.1.10] File does not exist: /usr/local/www/apache22/data/index
[Sat Sep 04 15:21:36 2010] [error] [client 192.168.1.10] File does not exist: /usr/local/www/apache22/data/index.htm
[Sat Sep 04 16:36:20 2010] [error] [client 127.0.0.1] File does not exist: /usr/local/www/apache22/data/announce
[Sat Sep 04 16:36:41 2010] [error] [client 192.168.1.10] File does not exist: /usr/local/www/apache22/data/favicon.ico
[Sat Sep 04 16:36:43 2010] [error] [client 192.168.1.10] File does not exist: /usr/local/www/apache22/data/favicon.ico
[Sat Sep 04 16:37:13 2010] [error] [client 192.168.1.10] File does not exist: /usr/local/www/apache22/data/test/test.html
[Sat Sep 04 16:40:42 2010] [error] [client 192.168.1.1] File does not exist: /usr/local/www/apache22/data/test/test.html
[Sat Sep 04 16:40:54 2010] [error] [client 192.168.1.1] Attempt to serve directory: /usr/local/www/apache22/data/test/
[Sat Sep 04 16:40:58 2010] [error] [client 192.168.1.1] Attempt to serve directory: /usr/local/www/apache22/data/test/
[Sat Sep 04 16:44:49 2010] [error] [client 127.0.0.1] File does not exist: /usr/local/www/apache22/data/announce
```

K.


----------



## BeastieBoy (Sep 4, 2010)

I guess it's a content-type problem.


----------



## kondziq (Sep 4, 2010)

What would you suggest to change it to ? 
My website code below: 


```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!--<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<div align="center"><a href="test/test.htm">Test</a></div>
</body>
</html>
```

K.


----------



## kondziq (Sep 4, 2010)

Ok, seems to work now. 
Problem was I had apache compiled without mod_mime: 



> mod_mime
> Associates the requested filename's extensions with the file's behavior (handlers and filters) and content (mime-type, language, character set and encoding)



Thanks everyone for help!
K.


----------



## DutchDaemon (Sep 5, 2010)

Ah, that was the _next_ question actually, because Apache appeared to be ignoring its 'magic' file (/usr/local/etc/apache22/magic) which links the text/html MIME-type and .html files.


----------



## kondziq (Sep 5, 2010)

Yup, seems so. Thanks anyway. 

K.


----------

