Protected PHP source code display

For developer is very convenient to see PHP source code simply adding extension phps instead of php.
If you would like to access control to the source code, here is how to do it.
For example, everyone could see page,
but only user joe will be able to see

cat /data/dir/htdocs/.htaccess
RewriteEngine on
RewriteRule (.*).phps$ /protected/sourcecode-phps.php [L]

cat /data/dir/htdocs/protected/.htaccess
AuthType BasicAuthName "Protected Access"
AuthUserFile /data/dir/htpasswd
require user joe

cat /data/dir/htdocs/protected/protected/sourcecode-phps.php
  if (file_exists($uri))highlight_file($uri);
  else echo "PHP source file not found: $uri";

This entry was posted in workday. Bookmark the permalink.

Leave a Reply