We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19309
    • 49 Posts
    Hi folks,

    I know that there are some threads in the forum covering various aspects of installing MODX in a subdirectory. But I have a little issue which seems to be not covered yet.

    What I want to do

    On a client’s webspace I want to install MODX Revolution not in the root, but in the subdirectory [tt]/modx/[/tt]. This way I can develop the new website directly on the live server without interfering with the current website. When the new website is ready to go live, I want to leave it in the subfolder, because I want to keep the root clean. But I don’t want the [tt]/modx/[/tt] to appear in the URLs.

    My solution so far

    The following steps are tested and work on my test server.


    • I install MODX in the subdirectory [tt]/modx/[/tt], just as usual.
    • When the website is ready to go live, I delete the [tt]/modx/[/tt] part from the URL settings in [tt]/modxtest/core/config/config.inc.php[/tt] – while leaving the path settings in the config file untouched.
    • I add the following rules to the [tt].htaccess[/tt] file in the root directory. (The [tt]RewriteCond[/tt] is necessery to use additional tools which are installed in other subdirectories. Requests to these tools should not be rewritten in any way. Only everything having to do with the MODX website should be affected by the rewrite rule.)
    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !^/(piwik|plesk-stat)
    RewriteRule (.*) modxtest/$1 [NC,L]


    Everything seems to work like a charm, except one nasty little thing.

    Now, the problem

    Opening [tt]http://domain.com/manager/[/tt] shows the login form just as it should be. But after entering the login information the browser is directed to the url [tt]http://domain.com/modx/manager/[/tt] which shows the empty login form again. But I am definitely logged in. When I call [tt]http://domain.com/manager/[/tt] manually, the manager interface shows up, just like it should be directly after logging in.

    It seems that a hidden field called “returnUrl” in the login form causes the unwanted behaviour after logging in to the manager.
    <input type="hidden" name="returnUrl" value="/modxtest/manager/" />


    Any ideas how I could change this, to make my “masked” MODX installation perfect?

    Thanks,
    Michael