2

I'm having trouble accessing a PHP page on my server through a symbolic link created as follows:

ln -s test.php clone/test.php

When I try to access the page, I get a 403 error.

Also, when I have checked created symlink in FTP, it shows folder icon there. (Though this wont be so big issue anyway.)

So simply I hope I could access clone/test.php through web browser. Is not there any good way to do this?

Ry-
  • 218,210
  • 55
  • 464
  • 476
Codemole
  • 3,069
  • 5
  • 25
  • 41

4 Answers4

4

Tricky one. You'll need to either edit an .htaccess file similar to the following:

Options +FollowSymLinks +SymLinksIfOwnerMatch

Or use a httpd.conf file:

<Directory “/”>
Options -ExecCGI FollowSymLinks -Includes -IncludesNOEXEC -Indexes -MultiViews -symLinksIfOwnerMatch
AllowOverride All
</Directory>

May be different depending on your configuration.

Luke Pittman
  • 870
  • 4
  • 12
  • Have you checked the owner & group of both the symlink and the file? They need to match and will need both be the same as the user/group that your site runs under. – Luke Pittman Jun 20 '12 at 03:31
  • Yes, they have same ower, owner group. And symlink 's permission is 777, target file's permission is 664 – Codemole Jun 20 '12 at 04:00
2

You're probably running into the symbolic link permissions error that only happens on Unix. Make sure that the Apache user (I'm assuming this is Apache) has access to the file pointed to, as well as every directory above it.

You'll also need to enable FollowSymLinks on your directory if you haven't already, as @LukePittman points out.

Ry-
  • 218,210
  • 55
  • 464
  • 476
2

Finally I have figured it out. When I tried with FULL PATH for source path, it works okay.

So when to create a symlink, it seems we have to put Full Physical Path for source file to which the symlink will link.

Codemole
  • 3,069
  • 5
  • 25
  • 41
0

I copied what Luke Pittman had posted, and modified what Codemole stated.

  1. Create your symlink in the htdocs folder (D:\xampp\htdocs)

mklink /J dynamic c:\somedirectory\www-dynamic

  1. Then alter your httpd.conf to allow execute access for php pages

    Options ExecCGI FollowSymLinks Includes IncludesNOEXEC Indexes MultiViews symLinksIfOwnerMatch AllowOverride All

Luke's solution just needs to loose the dashes "-". Before that, Apache wouldn't start up. Apache: Apache/2.4.26 (Win32) OpenSSL/1.0.2l PHP/7.0.22

Karl
  • 11
  • 3