Forum Moderators: phranque

Message Too Old, No Replies

Hiding PHP files

         

jeff schiller

5:35 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



I found this great thread (http://www.webmasterworld.com/forum92/2372.htm) but unfortunately it's closed. I'm a newbie when it comes to web design and this is exactly what I want to do. I want to completely hide the fact that I'm using PHP from the client.

Any help would be appreciated. I currently have the following .htaccess but URLs to *.php are not being sent a 404, the URL still gets through to the doc.

RewriteEngine on
RewriteCond %{THE_REQUEST} ^(GET¦HEAD)\ /.+\.php\ HTTP
RewriteRule \.php$ - [F]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)/?$ /$1.php [L]

ogletree

5:40 pm on Feb 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you really want to hide php you need to hide the .php as well. Make all your files .html and put

AddType application/x-httpd-php html

and put

ErrorDocument 404 /error.html

for the 404.

jeff schiller

6:26 pm on Feb 24, 2005 (gmt 0)

10+ Year Member



Nope, that doesn't work as it seems to confuse Firefox when it gets the "index.html" that is actually a PHP file.

For now, I've renamed all my PHP files with names that people will find it hard to guess and then I have some mod-rewrite rules that take URIs with .html and redirect them to the appropriate PHP URI. Of course accessing my .htaccess is also verbotten.

As long people don't try to guess the PHP filenames, is this foolproof?

bcolflesh

6:30 pm on Feb 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nothing is foolproof - check all the info here as well:

[us4.php.net...]

ogletree

7:27 pm on Feb 24, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I don't know what you are talking about I put that on all my sties and I have index.html. All it does is run index.html through the php engine. That should do nothing but load the page unless you have php code on the page. It would not make since to put php code on a page that does not have php.

jeff schiller

3:02 pm on Feb 25, 2005 (gmt 0)

10+ Year Member



Thanks bcolflesh that link was useful.