tags:

views:

80

answers:

4

If someone knew the link of one of my page or simply they made an assumption like http://ww.yourweb.com/index.php, this is a general assumption and if you put this link on DAP or other donwload manager, it will download file, with source code inside.

I want to stop other from stealing my code on this manner, is there a way for this?

+7  A: 

Your worry is unfounded. If correctly configured, the server will always serve the parsed file, never the unparsed PHP source file, no matter whether it's a browser that requests the file or some download manager.

Pekka
Can you please tell me how to configure this?
Starx
The default PHP/Apache configuration should be fine...
Amber
@Starx if a request to a `.php` file results in PHP source code being delivered, your server is misconfigured. You should take down the site immediately and post a question on serverfault.com detailing your server's exact configuration. @Amber is right, the default config should work fine.
Pekka
@macro, apache. @pekka, how to display the server configuration
Starx
@Starx if you need to ask that kind of question, you are not equipped to run a web server right now. That's not meant as a personal attack, but if you have a site running right now, you should take it down and start setting up the server from scratch. What kind of server are you on? Is it running at home? I'm off for tonight, but somebody else will surely be answering questions. Still, as I said, this really belongs on serverfault.com, that's where the server admin knowledge is.
Pekka
A: 

When a HTTP GET request is made on a php resource, the php script is executed by the interpreter on the server, and the resulting html is what is served to the client - not the .php file.

Robert
A: 

Well, I haven't heard of any case of a proper php file being downloaded (i.e. its source code instead of the parsed output).

However, if you want nobody to be able to download some file(s), you should look into mod_rewrite, as it is quite flexible. For example, if you use SMARTY and you don't want your templates to be downloaded (as they give some insight into the structure of your web page/cms/shop/whatever - i.e. make it slightly easier to hack), you can start off with the following rule:

RewriteCond %{REQUEST_URI} \.(tpl|tpl.php)$ 
RewriteRule .* - [F]

Of course that's not enough, but that's a point to start from.

Hope that helps ;)

dare2be
One of our (previous) web hosting providers had a problem with their Zeus servers where it would randomly display the source code instead of parsing the page. That was NOT good! We don't use them anymore even though they're one of the biggest in the country as this is a serious issue when it exposes everything.
niggles
+1  A: 

Your server is misconfigured, if running on Apache try adding the follwoing line in the .htaccess file of your root (or public_html) folder and see if you server starts parsing php file properly instead of returning source code.

AddHandler application/x-httpd-php .php
Marco Demajo