简体   繁体   中英

Custom MIME Type for PHP File

Okay, so I have a weird one for you all today. I'm looking into creating a custom MIME type for a .php file. I've read some pro's/con's on this and it won't be for much other than some experimentation to see what can really be done. My company's initials are TTP and so we decided it'd be kinda fun to have all of our .php pages re-written to a custom .ttp extension. I've attempted my normal cPanel X route with adding it in, and I've also tried adding the change into the .htaccess file. It work's perfectly fine until I change the application type to anything php.

AddType text/html ttp  // works
AddType text/x-php ttp // doesn't work
AddType application/x-php ttp // doesn't work
AddType application/x-http-php ttp // doesn't work

Some things that have come up was an issue that doing this renders the .php file and therefore makes it difficult for the browser to decide how to handle it. Any other ideas? I'm pretty sure that at the end of the day this won't be something the company will do, but they wanted to see if any experiment I could run will work.

The browser doesn't handle PHP. Content-Type doesn't matter here.

Look at your CGI or module configuration, to configure PHP to handle more than .php. For PHP as a module:

<FilesMatch \.ttp$>
    SetHandler application/x-httpd-php
</FilesMatch>

Handlers are specified with AddHandler . The mod_php handler is php5-script .

And the browser never handles PHP.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM