Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I click link to log file(I have a log of links like that) the firefox opens the file, but I want to just save it(like I do with PDFs). However I dont have log file defined as Manage File Type. How can I add log files there?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Firefox, like all other browsers, uses the HTTP Content-Type header to decide how to handle the page. In your case, the log file is served as text/plain, which is handled by Firefox internally. Whether the URL ends in .txt or .log does not matter.

If you have access to the web server, you could reconfigure it to serve .log files as, for example, application/x-log-file - either by editing .htaccess if the server is running Apache, or by reconfiguring the server itself.


If you don't have access to the web server's configuration, it's also possible to write a small script (in PHP or any other language) that would set headers and output the desired file:

<?php
if (isset($_GET["file"])) {
    header("Content-Type: application/x-log-file");
    readfile(basename($_GET["file"]));
} else {
    echo "<ul>\n";
    foreach (glob("*.log") as $name) {
        echo '<li> <a href="?file='.htmlspecialchars($name).'">'
            .htmlspecialchars($name)."</a>\n";
    }
    echo "</ul>\n";
}
share|improve this answer
    
cool idea, however If I make page like this <a href="bla.pdf">a</a> and click it the firefox saves the pdf to the file. he recognize the extension. I think there should be a way in adv ff options to add new recognizable types. –  IAdapter Dec 20 '10 at 6:03
    
@01: It doesn't. Your webserver tells it that the file is of type application/pdf. See for yourself. –  grawity Dec 20 '10 at 16:24

I got this to work with .rdp files with the following links:

share|improve this answer

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.