We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15136
    • 34 Posts
    Hey guys I couldn’t find an easy solution about moving a modx installation from a test directory to the root directory so I did my own research and tried a few things until I found something that worked for me.

    Admins, If this post belongs somewhere else or if there is an easier way then feel free to do with it as you will wink

    And so we begin...

    I had a test directory called /modx and I wanted to move it to the root (public_html) directory that way when somebody visited my site http://www.fighthookup.com they didn’t have to go to http://www.fighthookup.com/modx

    On my server the main directory is public_html. For you it might be something else like "www", "html", "home", etc.

    Here are the steps I took to move directories.

    Step 1: Compress all the files from my modx directory into a zip file and then moved that zip file into the public_html directory.

    Step 2: Unzip all the files into the public_html directory. (At this point all of your file paths will be jacked up because they are still pointing to "domain.com/modx" instead of just to domain.com)

    Step 3: SSH into your host, if you’re allowed to. (if not ask your host for assistance) Your username is usually the login name you use to login to ftp, password as well. Here’s how I did it. I opened the console (commmand line) and entered

    $ ssh [email protected] -p 22

    when you click enter it may give you with some information but ultimately it will ask you for your password. type it in and then hit enter.

    at this point navigate to the public_html directory. If you are unfamiliar with linux commands search google for basic commands.

    For me i just typed "cd public_html" without quotes.

    Step 4: We are going to use ’find’ and ’sed’ to find and replace all instances of files that contain the ’/modx’ directory in the file paths
    $ find /home/username/public_html -type f -exec sed -i ’s/\/modx//g’ {} \;

    let me explain this real quick. You want to find something that is inside of pubic_html. For me I couldn’t just type in "find /public_html" I had to put in the whole file path (/home/username/public_html. To get YOUR file path all you need to do is type in "pwd" without quotes and it’ll give you the path. Type that path right after "find" and right before "-type".

    Don’t worry about what all the other stuff does, if you care to learn about find and sed, just google it.

    We’re just going to focus on the part that says modx. Change that to whatever your test directory is named and hit enter. This will now scan all files for ’/modx’ and replace it with ’’ (deletes it). So now all my file paths will be changed from http://www.fighthookup.com/modx/whatever to http://www.fighthookup.com/whatever


    You should now be good to go. I know this may be a little difficult or over-simplified so feel free to ask any questions. I just finally found something that worked for me and decided to share with others.

    Thanks!
      2.2.4 Revolution
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      Thanks for sharing your findings! smiley

      There’s a sort of "how to" for Revolution in the docs: http://rtfm.modx.com/display/revolution20/Moving+Your+Site+to+a+New+Server
      It’s primarily for moving servers, but besides moving over the database the procedure remains the same.

        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.