0

I wanted to change the .php extension to .foo, to hide it for visitors. My webserver has cPanel installed, so I logged in and clicked on "MIME Types", and entered the following:

MIME Type: application/x-httpd-php
Extension: foo

The problem is that it's not being parsed as PHP, but instead is downloaded (when you click the link, a file containing all the code of that file is being downloaded)

How would I solve this?

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Vii Systems
  • 80
  • 11

2 Answers2

0

Add in httpd.conf or vhost.conf

<IfModule mime_module>
    AddType application/x-httpd-php .foo
</IfModule>

But best way to solve you problem is in using mod_rewrite

cetver
  • 11,279
  • 5
  • 36
  • 56
  • isnt AddType for media files, like jpg, flv, mp3 etc? I'm not sure that would be appropriate for php since the end user shouldn't be handling php files, only viewing their rendered output as html... I do agree it would be better to set Rewrite conditions to allow to urls without any file extension at all – WebChemist Aug 18 '12 at 20:40
0

If you have the necessary AllowOverride permissions to use .htaccess, try

AddHandler application/x-httpd-php5 .php .foo

For some reason our CentOS server needs x-httpd-php5, where as our WAMP internal server just uses x-httpd-php like you have (and -php5 will not work)

I have a CPanel based website and we used the above rule to set .html to be parsed as php, didn't even bother with the CPanel Mime settings... but there are other ways to determine if a server is running PHP so you're not really hiding that you use PHP from anyone who knows what they are doing

WebChemist
  • 4,393
  • 6
  • 28
  • 37