Custom php extension not being parsed

蹲街弑〆低调 提交于 2019-12-13 06:34:27

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12021380/custom-php-extension-not-being-parsed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!