I've been browsing for a minute now trying to find a way to create a relative symlink inside a relative symlink, and what I mean by that is this...

I have my CakePHP Templates Skeleton as a symlink inside one of my projects, inside my skeleton, I have a symlink to a plugin outside the skeleton folder, the idea being, I can symlink my CakePHP CMS Skeleton inside my projects, create an "Application" plugin outside the CMS skeleton symlink, and and the skeleton symlink point to my projects "Application" plugin.

By that I mean the following.

I have a CakePHP CMS Skeleton at the following path


The path to my project folder is below


I then symlink the CakePHP CMS Skeleton inside my project folder like so

/mnt/proj/mysite.com/cms-skel -> /mnt/proj/libs/cakephp/lib/Cake/Console/Templates/skel

Inside the skeleton I have a symlink pointing to an Application plugin

/mnt/proj/libs/cakephp/lib/Cake/Console/Templates/skel/Plugin/Application -> ../../Application

So inside the CakePHP CMS symlinked folder in mysite.com folder I have

/mnt/proj/mysite.com/cms-skel/Plugin/Application -> ../../Application

The issue is, that the above symlink points to


And I need it to point to


Any ideas on how I can do the above with symlinks is greatly appreciate, I am not even sure what to google at this point.

1 Answer 1


You issue is you're attempting to use a single relative link that will work within 2 directory trees, and yet the relativity of the link is not the same in these 2 trees.


I've created your directory structures starting at proj, but otherwise they're identical.

$ pwd

Here's the lib/ tree:

$ tree -lf libs/
`-- libs/cakephp
    `-- libs/cakephp/lib
        `-- libs/cakephp/lib/Cake
            `-- libs/cakephp/lib/Cake/Console
                `-- libs/cakephp/lib/Cake/Console/Templates
                    |-- libs/cakephp/lib/Cake/Console/Templates/Application
                    `-- libs/cakephp/lib/Cake/Console/Templates/skel
                        `-- libs/cakephp/lib/Cake/Console/Templates/skel/Plugin
                            `-- libs/cakephp/lib/Cake/Console/Templates/skel/Plugin/Application -> ../../Application  [recursive, not followed]

Here's the mysite.com/ tree:

$ tree -lf mysite.com/
`-- mysite.com/cms-skel -> /home/saml/proj/libs/cakephp/lib/Cake/Console/Templates/skel/
    `-- /home/saml/proj/libs/cakephp/lib/Cake/Console/Templates/skel//Plugin
        `-- /home/saml/proj/libs/cakephp/lib/Cake/Console/Templates/skel//Plugin/Application -> ../../Application

So if we were to look at the Application link in the 1st tree, lib/:

$ pwd

$ readlink -f Application

However, if we do the same analysis in the mysite.com/ directory we see our problem.

$ pwd

$ readlink -f Application

What's going on?

Well when you're in the mysite.com/ tree 2 levels above mysite.com/cms-skel/Plugin/ is libs/cakephp/lib/Cake/Console/Templates.

This should help to see it:

$ pwd

$ readlink -f ../../

I do not see a way around this given the differences in the number of directories within the 2 trees.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .