How to add new file extension to parse php code?

28 03 2011

For some reason if you need to enable a new file extension rather than .php to parse your php code, then this article will help you. But before you proceed, i would like to warn you an issue. If you enable other file extensions like .html to parse php code, every time an html file is requested, it is passed to php for parsing. It may have an issue with performance. However, if you need to enable more extensions to parse php code, then continue reading.

The process is very simple, all you need is to add the specified extension in your apache configuration file, which is httpd.conf . So you need to locate the file. Open the file and find the line –

AddType application/x-httpd-php .php

If its not there, add the line and then add your desired extension after .php separated by space –
AddType application/x-httpd-php .php .html

Finally restart apache server. This way you can add other extensions. What it does is, it binds a MIME type to a particular extension.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: