Web lists-archives.com

Re: Hard link shows php source code

On Wed, Jan 30, 2019 at 6:52 AM Jeffry Killen <jekillen@xxxxxxxxxxx> wrote:

I have been getting more familiar with hard links lately.
But I remember having created a hard link to a php source file.
The link name did not have the .php extension. So when I
used a browser to navigate to the link, the php source code
was displayed*. I figured out it was because the link name did
not have the .php extension. I thought that is a problem where
a php source code file could be read via an http request for a
hard link to it where the link name did not have the .php extension.

BUT; since, I have not been able to reproduce the same result.
I have been experimenting with hard and soft links to php code
files where the link names do not have .php suffix. Navigation
to these links produces blank pages; a good sign. I have also
used require(link name) with same results. No code is displayed.

The question is:
Does php anticipate this situation under the hood and recognize
the <?php tag even though it is reading a link to it with out the .php

* I am not sure that this won't happen again, sometime

Thank you

It depends on the web server that you are using. Default configuration of Apache usually handles this.

If you are using Apache, look for something like below in your apache configuration or .htaccess and learn more about this directives.

SetHandler application/x-httpd-php
AddType application/x-httpd-php .php

AddType: https://httpd.apache.org/docs/2.4/mod/mod_mime.html#addtype

Not sure if there is another way to tell web server to handle php files.

Jigar Dhulla