...

View Full Version : Setting the mime type on an external file



me'
01-05-2004, 05:09 PM
Okay. My CMS is nearly finished, but I have one problem. I want to create files that will contain individual blog posts, but I don't want these files to have extensions. Easy part: setting the mime type within the file. Hard part: getting the PHP code to run to actually change the mime type from text/plain to application/xhtml+xml.

In other words, I load an extensionless file with something like this in in:
<?php
header("Content-Type: application/xhtml+xml;");
?>Now, if I load this in a browser, the code will show, because the mime type is text/plain. The browser didn't think to execute the code to change the mime type, simply because it was served up as a text/plain file.

So my question: can I (without giving the file an extension) set the mime type on a file I create?

ReadMe.txt
01-05-2004, 08:52 PM
could you not call them .blog files or something, cos i been thinking about this and you can only tell apache to parse files with sertain extensions as PHP files, cant think how to do it without any extensions.

brothercake
01-05-2004, 09:46 PM
You can use ForceType in a directory to get all files to be parsed as PHP, but it only works on Unix Apache, not Windows.

Why do you need to the file to be extensionless?

If content-negotiation is the point, then why not have master templates which include() the blog posts, then the includes don't have to have file extensions because they'll be parsed as part of the main page.

If clean-URLs is the point, it's all much easier with mod_rewrite, then you can call them what you like on your end and the user will still see /path/to/article/

me'
01-06-2004, 04:34 PM
If clean-URLs is the point, it's all much easier with mod_rewrite, then you can call them what you like on your end and the user will still see /path/to/article/This sounds promising, but I've never heard of mod_rewrite. Is this a .htaccess thing?

Nightfire
01-06-2004, 04:48 PM
Yeah it's an htaccess and apache thang.

http://www.phpfreaks.com/tutorials/23/0.php

me'
01-06-2004, 05:08 PM
Originally posted by Nightfire
Yeah it's an htaccess and apache thang.

http://www.phpfreaks.com/tutorials/23/0.php thang eh? Dunno then... hmm...

thanks for the ref.

brothercake
01-06-2004, 09:56 PM
Here's another example - http://www.codingforums.com/showthread.php?s=&threadid=29810#post157483

me'
01-07-2004, 07:14 PM
Thanks.:D

*curses the windows OS once again. .htaccess is a [word removed] file name!*



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum