How to Map Custom Server File Extensions

How to Map Custom Server File Extensions

Server administration is a rarely discussed topic here on Build Internet, but today’s tutorial is a quick and easy modification that may prove useful to some. At the very least, it will save you from a “How did they do this?!” Google search someday.

This post also comes with a preface. While this may be a neat trick, it’s not something that should be done without a good reason. This could very well be a case of decorating instead of designing. With that in mind, let’s learn something to impress your (tech savvy) friends.

A Custom Example in Naming

Take a minute to load the URL below in a new window. The page content is irrelevant. What’s important is that the page is a custom (.OMR) extension running the PHP MIME type. Bonus points for anyone who got the acronym.

What’s going on? I’ve edited our server’s configuration file to handle the new OMR type as a PHP file. I’ve also set up the OMR extension to take priority over all other file types when loading a default index page. This process is remarkably simple.

This tutorial is intended for servers running Apache configurations. Statistically, this will include most of you.

Reinventing the File Type

File extension names are little more than letter combinations. Their real meaning comes from generally accepted standards. A file with JPG extension is expected to be an image, and programs will default accordingly. These are the. But these definitions can be changed.

Think of it like a vanity license plate for files. Certain sites, like the financial management site Mint, use custom extensions (e.g. as an added layer of security on their pages. By obscuring the coding languages and systems used, they are adding one extra step to getting through server security. The majority of us aren’t running bank-level operations though.

Online file formats are specified using something called MIME types. A file’s MIME type controls how it is to be handled by servers, clients, etc. Many types come predefined (e.g. JPG, HTML), but we’re also able to add in new ones. In the same way that both HTM and HTML represent the same MIME type, we can tell the server to treat a custom file extension like an existing definition. A file extension of XYZ could then become another name for PHP documents.

Declare a New File Type

The code for this is surprisingly short and sweet. Keep in mind that the # symbol represents a commented line, and is not actually part of the required code. This block can be copied directly into either of the two methods outlined in the next section, and does not require any special prefacing to work.

Putting it in Action

You can put append this code to either of the files outlined below. I recommend setting up an isolated directory locally using MAMP/WAMP in order to keep from potentially damaging global settings. Keep in mind that the modified htaccess file will only affect the directory it is in, and makes damage control much simpler.


Create an .htaccess file in the root directory and append. The difference between htaccess and httpd.conf is how the file is accessed. The htaccess route is better for controlling specific directories or fixes to the Apache setup. The downside is that since the htaccess file is called for each page load, it can add extra load to the server.

To get a better understanding of how .htaccess files affects server directories, take a look at the excerpt from the Apache documentation:

The configuration directives found in a .htaccess file are applied to the directory in which the .htaccess file is found, and to all subdirectories thereof. However, it is important to also remember that there may have been .htaccess files in directories higher up. Directives are applied in the order that they are found.


According to the official Apache documentation, best practice dictates that the majority of directives should be made through the configuration files, and not htaccess wherever possible. The definitions found in httpd.conf are loaded when the server starts instead of on individual access, which may offer a slight difference in resources required. Keep in mind that any edits made to the .conf file will not take affect until the server has been restarted.

The process for editing your server’s httpd.conf file will vary based on hosting provider. This blog is hosted on a dedicated virtual server on MediaTemple, where the recommendation is to edit vhost.conf file in place of the main httpd.conf file. Refer to your hosting provider’s support documents for more. If you are unable to edit this configuration directly, the htaccess file may be the next best alternative.

Use in Moderation

You now have the tools and directions needed to create new file extensions on an Apache server. I strongly recommend against making changes for the hell of it. While this may be a nice trick, the average website probably doesn’t need a creative mix of new filenames (e.g. Ars Technica and .ars files) to suddenly show up. Arbitrarily applying this to your site would cause a considerable amount of confusion among search engines, users, and server configuration. Conventions exist for a reason.

Have you seen custom file extensions used effectively? Are you a server genius with some considerations to add to the discussion? Please share in the comments below.

Further Reading

Interested in finding out more about what Apache and htaccess modifications can do for your site? I’ve included a few links below to continue the research.

  1. Internet Media Types on Wikipedia
  2. Tutorial on editing httpd.conf for MediaTemple
  3. The htaccess Cheat Sheet

Posted Thursday, March 11th, 2010 · Back to Top


Add Comment

23 Comments 6 Mentions

  1. Hitesh Chavda Author Editor

    of course,

    OMR ( Optical Mark Reader)


  2. Max Author Editor

    Of courde, OMR = Oh My Russian… is so horrible ))


  3. Arvind Author Editor

    It is indeed a good technique. The reasons – It is gives a higher points in security (very little actually as the attacker wont know the script language used in once glance). Second While declaring html as php and using a good cache header you’ll increase performance


  4. Jonathan Author Editor

    Very nice.

    However, security through obscurity is not security at all.


  5. Josh Author Editor

    Neat trick! I might use that someday. :)


  6. Amberly | Web Designer Author Editor

    Interesting read.


  7. Alex Author Editor

    I’ve seen this used on a few corporate sites my agency has worked on for language changes. We’ll often have an index.en and an for english and french.


  8. Ryan Hamilton Author Editor

    Gonna take a shot in the dark and say that .omr is referring to One Mighty Roar. Great read.


  9. Michele Author Editor

    One of the largest property sites in Ireland uses custom extensions like this and has done for years:

    I’m not sure what benefit, if any, it brings, but it can have its uses if you need to use .html files but want them to be able to parse php, for example


  10. Saddam Azad Author Editor

    I fail to see the point of custom file types used for websites. The .ars extension on Arstechnica might as well have been .html (not that the readers would notice or care)

    It might a good idea to use .html for SEO purposes but inventing obscure extensions is rather silly, me thinks.


  11. Vamsi Author Editor

    has this got any adverse effect on SEO ?


    • Zach Dunn Author Editor


      That’s a good question, and truthfully I don’t know. I’d imagine that part of the search engine algorithm evaluates the file type for each page. If it’s a custom one, the crawler may eventually figure it out, but it probably doesn’t make it easy.


  12. Atul Kash Author Editor

    I guess this is strictly for new projects. I’ll have to modify all my links if I were to implement this.


  13. Michal Author Editor

    Hi, I found many informations about file extensions at


  14. Brian Author Editor

    You can actually use these tricks to preserve SEO, in conjunction with mod_rewrite.

    Say you’re given a website of highly ranked static HTML files and wanted to use PHP instead. Without having to change file extensions or file names, you could change PHP as the handler of HTML files. It’s all transparent to the end user and will not affect your rankings.

    Or you could rewrite certain URLs of HTML files to another name or file extension, if you used mod_rewrite.


  15. steve Author Editor

    very good for hacking sites, huh?
    you get access to a site, modify the .htaccess to make .jpg or .gif executable as php.

    leave behind a well placed jpg (with some appended php code)
    and voila!

    heck, you could even have the php code execute via a img tag


    • Virtual Office Dublin Author Editor

      Extension is really very important part of the file as it will elaborate the type of file and what does the file belong to. This technique is very effective and useful providing a very secure and faithful way of mapping. This blog helped a lot to tell the interesting and important thing to me as I was not fully aware of it.


  16. John [email protected] server Author Editor

    Wow this is really informed me a lot and learned many things from this post and using this seems interesting, glad to share your techniques Thanks.


  17. Kent Author Editor

    Thanks, very cool…


  18. Seon Poppcile | web designer Author Editor

    nice read! think i’ll bookmark this one for later use. Thanks!


  19. KottlerDevelopment Author Editor

    MediaTemple uses this trick pretty extensively. Then again, when you have dozens of server techs and developers around, why not!


  20. oavsett hur ditt hus ser Author Editor

    There are some interesting cut-off dates in this article but I don’t know if I see all of them center to heart. There is some validity however I’ll take maintain opinion until I look into it further. Good article , thanks and we want extra! Added to FeedBurner as well


  21. boston virtual office Author Editor

    Hi to every one, it’s really a fastidious for me to visit this website, it consists of precious Information.



Build Internet by One Mighty Roar. Since 2008.