1

I have symlinks to certain directories because the directories' names have non English characters that I got fed up trying to get apache's rewrite rules to match. There's a bounty on that question trouble with utf-8 chars & apache2 rewrite rules anyone wants to go for it, and from the looks of things a lot of people would like to see a general solution to this problem, but meanwhile I made a plain ascii symlink to each of these offending directories. Now the rewrite rules are back to just alpha and _ and - and my security concerns are less and it loads the resources I want. But I still need the actual target directory name for display purposes. I googled "PHP directory info, PHP symlink" but didn't find anything. I need to do something like this:

if (is_symlink($myResDirName)) {
    $realDirName = follow_symlink($myResDirName);
}
Community
  • 1
  • 1
Colleen Kitchen
  • 1,049
  • 1
  • 11
  • 20

2 Answers2

7

You're looking for is_link

Matt
  • 40,711
  • 6
  • 89
  • 98
  • That's what you are looking for. If you need to find things like these in the future, consider googling something like "php symlink"..in this case you are taken to the symlink function on the oficial PHP website..then, at the end of each function description you have "related functions".. you can jump between them to see if any fit your needs. At least it was like this that i found this function too ;) – Gonçalo Queirós May 28 '10 at 21:21
  • I tried is_symlink too. Bad on me for not thinking of the right keywords and for missing the fine print at the bottom. Usually if it's in php.net I find it. And thanks! – Colleen Kitchen May 28 '10 at 21:41
  • is_link returns false for me (an no, I am not using Windows). Anyone have an idea why? – Antony D'Andrea Feb 06 '15 at 10:14
  • 1
    It's important to use this without a trailing slash, or it will return `false` since symbolic links are files. – Evan Mattson Sep 15 '17 at 07:25