-2

I know that we can hide PHP extensions on URL bar. Can we hide PHP extensions when the user view source code? For example, in the index.php page (on url bar it is abc.com/index) And I view the source code, the .php extension is still there (in <a> tags). Can I hide it?

WebDeg Brian
  • 802
  • 1
  • 7
  • 21

3 Answers3

1

If you already have configured your web server to interpret any chosen extension like ".do" as a php script instead of extension ".php", then all your links must use this chosen extension.

So it is not that you "can", it is you "must" use ".do" in your HTML pages.

Setop
  • 2,262
  • 13
  • 28
1

If you configured your server (Apache/Nginx) to work with example.com/ and (lets say an about.php) example.com/about, the links would work.

Apache htaccess example config:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_FILENAME}.php [NC,L]

Thought this is just for php extensions. Though this will only help with links, lets say you are requiring a file you'll still need extensions though that wouldn't show up in element inspector/source code from browser.

<a href="./">Home</a>
<a href="./about">About</a>
Jay
  • 70
  • 8
0

The PHP code is not visible on Server side, when you click "View Page Source", however if you submit your URL for optimisation/analystics/SEM companies (bing or google or any other such company), they can get the complete PHP server code. So, it's not foolproof. Even the webpage that you installed on webhost, the PHP code can easily be viewed by the webhost employees itself. So, it's not safe (if your PHP code is critical for you).

To hide your code, you can write your main functionality in Java and port your compiled Java code to the webserver. This way, nobody can decode your code and yet you are able to achieve what you want to do.