What is MIME type "text/x-prolog"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

text/x-prolog is a MIME type used to label files containing Prolog source code.
It tells applications that the file holds plain text with embedded Prolog logic. This helps code editors and IDEs to enable proper syntax highlighting and code analysis for logic programming.
Files using this MIME type include those with the extensions PL, PRO, ECL, and PROLOG.
Additional details on the Prolog language can be found at Prolog on Wikipedia.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/x-prolog    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/x-prolog">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/x-prolog');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

Why is my .pl file treated as a Perl script instead of Prolog?

The .pl extension is ambiguous because it is historically used for both Prolog and Perl. If your server is configured to treat .pl files as text/x-perl or executable CGI scripts, it will misinterpret Prolog code. You must explicitly configure the server to serve these files as text/x-prolog.

How do I configure Apache to serve Prolog files correctly?

You can add a directive to your .htaccess file or main configuration. Add the line AddType text/x-prolog .pl .pro .prolog to ensure Apache sends the correct MIME header for Prolog source files.

How do I set the MIME type for Prolog in Nginx?

In Nginx, you should modify the mime.types file or your server block. Add the entry text/x-prolog pl pro prolog; so that Nginx recognizes extensions like .pro and .pl as Prolog source code.

Can web browsers execute text/x-prolog files?

No, web browsers do not natively execute Prolog logic. When a browser encounters text/x-prolog, it will usually display the file as plain text or prompt you to download it. To run the code in a browser, you would need a JavaScript-based Prolog interpreter library.

What is the difference between .pl, .pro, and .prolog extensions?

Functionally, they all contain the same Prolog source code. However, .pl often conflicts with Perl, while .pro can conflict with IDL or Qt project files. Using .prolog is the most unambiguous option, though it is longer to type.

Is text/x-prolog safe to open?

Yes, files served with this MIME type are treated as plain text source code. Opening them in a text editor is safe, but you should be cautious about executing downloaded code in a local Prolog interpreter without reviewing it first.

What does the "x-" prefix mean in this MIME type?

The x- prefix indicates that text/x-prolog is a non-standard or private subtype, not officially registered with the IANA. Despite this, it is the de facto standard used by most web servers and operating systems to identify Prolog files.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.