Welcome, Guest. [ Log In ]
Question   What extension should my php files have?
Search KBase


Top 5 in this Area:
1. What's the difference between PHP-CGI and PHP as an Apache module?
2. PHP Security
3. Compiling your own custom PHP
4. Can I run a phpbb forum (message board) on my site?
5. Do you support this PHP module or extension?

 
What extension should my php files have?
Our servers are configured to recognize files with the extensions .phtml, .php, .php3, .php4, or .pcgi as PHP. If your PHP files aren't working, it may be that you haven't named them with a proper extension.

If you want a php page to be your default page (i.e. when somebody goes to yoursite.com you want it to show them a php file), you must name it either index.phtml or index.php (and make sure you don't have a file named index.html in the same directory).

Also, you can use whatever extension(s) you want for PHP files by placing a .htaccess file in your web root directory with a line similar to the following:

AddType php-cgi .html .htm
Where '.html .htm' are all the extensions you wish to use.

Last updated: Jan 23, 2004.

User Post (2005-08-06 10:49:26 by akamarketing)
If you are not running php as a cgi then the line:

AddType php-cgi .html .htm

Will not work. The standard 'AddType application/x-httpd-php .htm .html' didn't work either. So you will need this line:

AddHandler application/x-httpd-php .html

This does work!
User Post (2005-01-16 15:22:55 by sgrainer)
I tried to password-protect a directory after using the "AddType php-cgi .html" statement mentioned above in a higher-level .htaccess file, and kept receiving the error message: "No input file selected."

I fiddled around and found that the AddType statement was causing the password protection to break for some reason. (When it was removed, password protection worked perfectly; otherwise, I would receive the same error as above and no login dialog box.) Instead of using the "AddType php-cgi .html", I used "AddType application/x-httpd-php .html" and both the PHP parsing and the password protection worked. Hope this helps others who might have the same problems.