Header Sent for Static Extensionless Files
I am plannig to set up something similar to the following: https://wordpress.stackexchange.com/questions/6109/how-can-i-lock-down-an-old-wordpress-install-i-dont-intend-to-update
Basically the folders and files are generated like a cache for a php site.
What header info is sent for extensionless files? Is the header info stored in the text file like the modified date or something else?
I would like to stop using extensions for all site content. For examp开发者_C百科le:/about - html page
/js - my sites javascript with appropriate header info
/logo - my sites logo
etc.
Are there any negatives or repercussions in setting extensionless files. What about if I set up the caching system?
There are multiple options to set headers for static files, if they have no extension. For a whole directory it's easiest to use DefaulType
in the .htaccess
:
# js/ directory
DefaultType application/javascript
The sibling ForceType
is sometimes also useful:
<Files about>
ForceType text/html
</Files>
But you can also set headers for individual files using e.g. a RewriteRule
:
RewriteRule logo - [T=image/jpeg]
And another option is to use mod_meta
. This allows to have each static file accompanied by a .meta file, which defines the sent MIME type.
- Headers are being attached by the web server
- Send a static file and you can see with Firebug or a similar tool what headers are being sent
- To override a header that was attached by the server, you can use PHP's
header
function. Use the same header name as the one you want to override. For example, if you want to override\cancel theContent-Length
header you would doheader('Content-Length: ')
(Although for this specific header it makes no sense to cancel it). - To attach headers to static files, you will need to do that (in Apache) in .htacces or the main configuration file of the Apache.
精彩评论