Site Root vs Document

I tend to use ‘Document’ in my site settings. I have no specific reason for it other than I really haven’t had any issues with it.

Which do you guys use? Reasons? Pros and cons of either one?

1 Like

I use site root as I tend to write in reusable modules

For example, the menu had issues with was used in two separate areas of the site, the area dynamically changing based on if the user was logged in or not

So non logged in users see the menu from the root of the site so relative to document is they are in same directory

However when the user is logged in they are running pages in the directory “users” but the same menu is needed

Using relative to document will not work within the menu as the “relativity” is not fixed as the directory location is not fixed
So for example

The menu links to a login page, login.php in the root directory and also a link to a “my account” page in the “user” directory myaccount.php

so login.php is in the same directory when in root, but a directory above when run from the “user”; myaccount.php is in a directory below “user/myaccount.php” but in same directory when in users.

The solution is easy when relative to site root as the full path is used in each case i.e. /login.php and /user/login.php and that remains correct regardless of where it is called form

That is why i prefer relative to site rather than document


Usually you stick to document relative links because they are shorter.

However when you use routing links can’t be always relative and need to be site root relative.

But stick for now on document relative as we have a small bug in the latest update that also rewrites the paths on server side includes to be root relative and that is not necessarily

Just a thought @George, should there be any need to do any URL rewriting where links are relative to site as they will always point correctly to the target even if saved elsewhere?

You make some very valid points, Brian. I suppose the reason I rarely have issues that my files are usually always in the site root anyways so it really doesn’t make a difference if it is document or site root.

So if I plan to use routing in the future I should get used to using site root in my settings?

personally I just dont see a down side of relative to site, especially if you have complex file structures. recent site has multiple areas, public, admin, users, agents and data entry. some routines are common so cn be called from any of those areas and still work. As to routing, need to see how vthe team resolve things and if they can effectively 'firewall the two processes

Is this still the true way of doing a SPA site? Site Root?