Colleen  Kitchen
Colleen Kitchen

Reputation: 1069

Is there a way in PHP to check if a directory is a symlink?

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);
}

Upvotes: 1

Views: 5091

Answers (2)

Matt
Matt

Reputation: 44068

You're looking for is_link

Upvotes: 7

Related Questions