led
led

Reputation: 1684

Prevent PHP file from downloading

I just found out that everyone can download my php files by pressing the alt key and left-clicking.

However, every other website prevents visitors from downloding their source file by replacing the download with a static html file.

I don't know how to hide my source files. Can anyone help? Did I somehow mess up my server settings?

Upvotes: 1

Views: 1131

Answers (4)

deed02392
deed02392

Reputation: 5022

They're not downloading your PHP files, they just download the static HTML produced by your PHP script. The ability to download the PHP source is down to the server configuration.

Upvotes: 5

MMag
MMag

Reputation: 43

PHP is interpreted and spits out some output (using echos and print statements) that is sent to the browser AS plain HTML. They CANNOT "download your PHP". Unless you're offering the source code files .phps (conventionally).

Upvotes: 2

Mihai Vilcu
Mihai Vilcu

Reputation: 1967

They are no downloading the actual php code that you have. They only get your output just like your browser does. you can do the same thing if you press CTRL + S on the page.

So you don't have to worry about that as long as your php code id compiled.

Upvotes: 2

Marcin Orlowski
Marcin Orlowski

Reputation: 75619

You are saying that if you click on the file.php normal way it runs as expected and you see output of that PHP script but if you click with ALT then you can download source of that file? I really doubt so. All you can download is probably output of your script.

Upvotes: 3

Related Questions