View previous topic :: View next topic |
Author |
Message |
boniek Guru
Joined: 26 Mar 2005 Posts: 373
|
Posted: Sat Sep 17, 2005 9:27 am Post subject: Apache and displaying source files |
|
|
I have local apache-2.0.54-r30 server and want to view source files (files with .c .c++ .h etc extension) inside of web browser. Can anyone give me a hint how to do it? TIA _________________ [HOWTO]New freetype subpixel font rendering for lcd monitors |
|
Back to top |
|
|
ekutay l33t
Joined: 30 Mar 2005 Posts: 636 Location: Berlin
|
Posted: Sat Sep 17, 2005 6:38 pm Post subject: |
|
|
If not otherwise configured and DefaultType text/plain is set and you do not want to beautify, you can point the browser on the URL of the file. _________________ -- erol |
|
Back to top |
|
|
boniek Guru
Joined: 26 Mar 2005 Posts: 373
|
Posted: Sat Sep 17, 2005 7:51 pm Post subject: |
|
|
I don't know if I understand you correctly but typing URL of the file gives me download box. What I want is to display file inside browser (just as plain ASCII files without extension) _________________ [HOWTO]New freetype subpixel font rendering for lcd monitors |
|
Back to top |
|
|
ekutay l33t
Joined: 30 Mar 2005 Posts: 636 Location: Berlin
|
Posted: Sat Sep 17, 2005 8:26 pm Post subject: |
|
|
Eyeyey, I was not precise, sorry. Not the real file URL like /home/user/sources/project/include/myfile.h. The file must be served by apache otherwise the browser will try to load the file manually and offers you something of its choice, eg. download, open with editor and so on. If the apache delivers the file as text/plain, the browser will display the file as plain text, at least it should do.
Eventually you should be able to type http://localhost/sources/project/include/myfile.h in the addressbar of your browser, when, here in my little example, the sources directory is deployed in the document root of the webserver. _________________ -- erol |
|
Back to top |
|
|
boniek Guru
Joined: 26 Mar 2005 Posts: 373
|
|
Back to top |
|
|
ekutay l33t
Joined: 30 Mar 2005 Posts: 636 Location: Berlin
|
Posted: Mon Sep 19, 2005 9:43 am Post subject: |
|
|
What is printed when you do Code: | grep "^DefaultType" /etc/apache2/httpd.conf |
If it is application/octet-stream you could change this to "text/plain" if this suits. Alternatively you could add the file suffix to /etc/apache2/mime.types.
Set
Quote: | text/plain asc txt |
to
Quote: | text/plain asc txt c h c++ |
Otherwise you could invent a small cgi script to accomplish that task, which would give you the option of beautifying the output. _________________ -- erol |
|
Back to top |
|
|
boniek Guru
Joined: 26 Mar 2005 Posts: 373
|
Posted: Mon Sep 19, 2005 11:40 am Post subject: |
|
|
My apache uses /etc/mime.types for mime configuration. What I did to make it work as I wanted was commenting out following lines in mentioned file:
Code: |
#text/x-c++hdr h++ hpp hxx hh
#text/x-c++src c++ cpp cxx cc
#text/x-chdr h
#text/x-csrc c
|
modifying following line:
Code: |
text/plain asc txt text diff pot c h c++ |
and rebooting.
Thanks for help ekutay. _________________ [HOWTO]New freetype subpixel font rendering for lcd monitors |
|
Back to top |
|
|
|