How to brand your website’s URL, Part 3: custom file extensions

Written by Verne on July 27th, 2007

When you see a .doc, you know exactly what kind of file it is, and you probably know what company is behind it. Why shouldn’t this form of brand recognition transcend into the online realm? Why should we be constrained to the .html’s and .php’s of today’s web world?

This third installment of How to brand your website’s URL continues to show you how you can and should be customizing even the slightest details of your website’s URL by using your own cutomized file extensions.


Why should I use a custom file extension?

Quite simply, it’s another easy way to mark what’s yours as yours. For the web designer who understands the value of leaving their signature in the footer of a site they’ve designed, the custom extension serves as yet another way to leave your call sign.

Got an acronym or short word associated with your brand (or one that you’d like to get associated with your brand)? Flaunt it! Want to promote the technology behind your site as being something new and unique? Do it! You’ll wow the common user and make other site publishers jealous.

So how do I do it?

Creating your own custom extension is actually a fairly easy process, though it’ll take a little bit of work with your server’s .htaccess file. If you don’t know what this is, don’t worry, I’ll walk you through it.

Say for example, we’d like to create a new page using the custom extension .cb (for creative briefing, naturally). Furthermore, this new page will contain PHP scripts, so we need to make sure the server parses it as if it were a .php file. No problem. First, we find our .htaccess file.

How do I find my .htaccess file?

First, check the route directory of your site for a file that is labelled as “.htaccess”. If you find one, download it, and open it up in your preferred text editor. If you don’t have one, create a new text file and rename it to “.htaccess”.

Done. Now what?

To add a custom file extension, it’s just a matter of telling the server what file type (or Mime Type, as we’ll learn later) is associated with your new extension. In this case, we’d like to tell the server to treat .cb as if it were a PHP (.php) file.

The general form of the syntax to get this done is as follows:

AddType <Mime Type> <Custom Extension 1> <Custom Extension 2> <Custom Extension 3>

The Mime Type is a specific name given to a type of file that is used to tell the browser how to handle your custom extension. In this case, the Mime Type for a PHP file is application/x-httpd-php.

So, with your .htaccess file opened, you’ll want to add the follow line:

AddType application/x-httpd-php cb

In fact, because you want to ensure that other files with the .php extension still work, you’ll probably want to add .php to the list too, like so:

AddType application/x-httpd-php cb php

Save. Upload. Dance in branded excitement.

What about other Mime Types?

You can repeat this process for just about any Mime Type and any custom extension you want to use. All you need to do is find the correct Mime Type and choose a suitable extension. For example, the Mime Type for HTML files is text/html.

Don’t get too carried away with it though, and be sure to do it only if it serves a real purpose (i.e. the branding of your URL). Remember that similar files were given specific file extensions in the past so that they’d be easier to organize and identify. So don’t go wild and start updating your image files and PowerPoint files with custom extensions unnecessarily.

But for those necessary occasions, I’ve created a list of 99 common Mime Types for you to use to your heart’s content.

Enjoy and happy branding!

8 Responses

  • sean

    Hi,
    Just a question on branded,
    I used
    AddType application/x-httpd-php cb php

    in .htaccess but it gives server error message.
    with php codes inside a file.

    basically i did exactly as you guided me on your site, but it doesnt work… it gives error for php codes.
    any suggestions?

  • Verne

    Hi Sean,

    What are the errors that it’s giving you? Did you remember to change the “cb php” part to the custom extension that you’re using?

    Paste me some details here and I’ll do my best to help you out!

  • sean

    hi Verne,
    Thanks for your great help.

    OK,
    1-I created a .htaccess with ” AddType application/x-httpd-php cb php ” in it.

    2-created a file with a simple php code saved it as test.cb

    uploaded and here is the link:
    http://www.axha.net/test.cb

    content of test.cb{ php“; ?>}

    I did change the permission of the file to 644, 755,777 but still not working.

    I have test it with html mimetype and only html codes are working but not php codes.

    Am I missing anything?

    Thanks for your help Verne,
    Sean

  • Verne

    Hi Sean, it seems like your error has more to do with a syntax error within text.cb than with the .htaccess line.

    I’ve taken the liberty of creating a test.cb of my own. In my .htaccess file, I have the following line:

    AddType application/x-httpd-php cb

    Then in test.cb, I have:

    <?php echo "If you can read this, then this page is working!"; ?>

    It seems to be working fine. Look into the PHP you have in your test file and make sure there aren’t any errors (test it by just echoing something simple).

    If that fails, then maybe it has something to do with your server environment. I’m no expert in this area, but I know different global variables being turned on or off can sometimes make the difference.

    Hope that helps!

  • Joey Buzzsaw

    I’m having a problem, too…

    Even though I’ve got the entire command correct in my .htaccess file, when I visit the page, my browser doesn’t know what to do with my custom file and tries to download it.

    I’ve got this in my .htaccess (I’m trying to make a social site, and .wex is my speak for “web executable”.)

    AddType application/x-httpd-php wex

    When I click on your link, as well, my browser doesn’t handle it, and asks me which program I want to open it with.

  • Willem

    Thanks so very much for taking your time to create this very useful and informative site. I have learned a lot from your site. Thanks!!

  • Hemal Shah

    Hi Verne,

    Thanks for this article. I have been looking for something as simple like this. I wanted ask you one thing.

    If I want to customize the url for HTML (as you have shown for PHP) how do i go ahead?

  • JD

    I’m trying this method too, but something doesn’t work. Instead of parsing PHP and displaying the file, the browser just download the file like an attachment. Trying to work out what else needs to be in addition to this…

    Thanks.

Leave a Reply