Question

I'm trying to hide the fact I'm using PHP on one of my site pages and I'm wanting to run it through the PHP parser (just that page not them all) so I can call it filename.html as usual. I have tried a few Apache directives I found online and have a few in my .htaccess file (hotlinks and for a 404 page).

When i use one of the scripts (in my .htacess) for the PHP purpose, the page wants to be saved/downloaded (like a vcard does) and a box shows - with no page to view. Can anyone please help. I'm new to PHP but believe a module might be needed or that it could be to do with the config of my server.

Was it helpful?

Solution

You should leave the page with a .php extension and have Apache handle the file as a normal PHP file. Then use a RewriteRule in your htaccess settings to hide the php file as follows:

RewriteEngine on
RewriteRule ^yourfile\.html$ yourfile.php

OTHER TIPS

There is no real need to hide the fact that you are using PHP, but if you really want to parse PHP in html files you need to edit your Apache httpd.conf file. Open it up in a text editor and find a group of lines that looks like this:-

AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php

(Yours may be slightly different)

Then add

AddType text/html .html

restart Apache and php in html files will be parsed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top