Home > Tutorials > HTACCESS Tutorials > Using Custom Extensions

Using Custom Extensions

Ever wondered how Google makes some of their pages have the extension .g? This is a fairly easy procedure really, and htaccess does a great deal in helping us accomplish this. First decide what you want the new extension to be, for our purposes we will use the extension of .purple (simply because it makes sense – what with the site being called Rapid Purple and all). Now we want all files with the .purple extension to be treated as PHP files, so we will add the following line to our .htaccess file:

AddHandler application/x-httpd-php .purple

This little command will tell your server to treat each file with the extension of .purple as if it were a PHP file. There are tons of handlers you can use for your custom extension, and listing them all is well beyond the scope of this tutorial, however here are just a few common ones:

  • Shockwave Flash: 
    application/x-shockwave-flash
  • XHTML: 
    application/xhtml+xml
  • ZIP: 
    application/zip
  • HTML: 
    text/html
  • CSS: 
    text/css
  • Java Script : 
    application/x-javascript

About Michael Boguslavskiy

Michael Boguslavskiy is a full-stack developer & online presence consultant based out of New York City. He's been offering freelance marketing & development services for over a decade. He currently manages Rapid Purple - and online webmaster resources center; and Media Explode - a full service marketing agency.

Check Also

How To Populate A DIV via an HTML SelectBox, PDO, and jQuery

Imagine you have a database full of information, and you want to let users browse ...

Like every other website, this site uses cookies to analyze our traffic. Cookies may also be utilized by our advertisers and partners. By using this website you agree to the use of said cookies. More Information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings, continuing to navigate past this message, or you click "Accept" below then you are consenting to the use of cookies on the Rapid Purple website.

Close