We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 27672
    • 168 Posts
    right up front, i don’t do much with server setup htaccess type stuff... that being said, here is what i’d like to do.

    i am working on a new site for someone whose /public_html/ is quite messy (all static stuff), and i’d like to create my modx site under /public_html/modx/, and then when it’s approved to launch, i’d like to have all www web traffic pointed into that /modx/ directory (without "modx" appearing in the url of course). can this be done via .htaccess?

    what’s the best method? i know while developing i’ll have this:
    RewriteEngine On
    RewriteBase /modx/

    in the /public_html/modx/.htaccess, but when it’s ready to launch is there something i can put in an .htaccess file in /public_html/ to point that to the /modx/ directory, but not have "modx" appear in the url?

    i had tried something like this on a previous project:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www\.)?domain_name_here\.com$
    RewriteCond %{REQUEST_URI} !^/modxrevo/
    RewriteRule ^(.*)$ modxrevo/$1 [L] 

    which put me into the correct subdirectory, but i still have "modxrevo" in the url, unfortunately i had to bail on this because the site had to be launched "yesterday", so i literally couldn’t spend a minute more on it, and ended up just putting everything in /public_html/.

    any insight would be greatly appreciated! thanks!
      • 6228
      • 249 Posts
      At a glance, I think all you need to do is change [tt][L][/tt] to [tt][R, L][/tt], perhaps [tt][R=301, L][/tt] would be better. In fact, if this is co-existing with MODx’s htaccess code, you may need to omit the [tt]L[/tt] for friendly urls to work properly.

      I would seriously reconsider moving your web root.

      A better idea would be to move all of the non-essential html files out of the public_html directory into a backup folder, rather than move the web root via htaccess which could turn out to be a maintenance nightmare for you.

      Edit:
      Of course you will need to take into consideration any documents or files that might be linked from elsewhere or indexed in search engines. I would not just move html files haphazardly.
        lo9on.com

        MODx Evolution/Revolution | Remote Desktop Training | Development
        • 27672
        • 168 Posts
        thanks for the reply, i was picturing taking all the "stuff" that’s currently in the /public_html/ directory and moving that into another sub directory, so in the end the /public_html/ would look something like this:

        /public_html
        --->/modxrevo
        --->/old_stuff
        --->.htaccess (the one that bumps all www traffic into the /modxrevo directory)

        does this seem like a good/bad/ugly solution? i should add, this isn’t my server, and i don’t have complete access to it, so this would be done via ftp as much as possible, so i can’t really get ’up’ from /public_html/
          • 18373 ☆ A M B ☆
          • 3,141 Posts
          I’d also just move it in the webroot. After all, that’s what the webroot is for, right? smiley

          Backup the rest of the files and either delete or put in a sub dir.


          If you’re worried about missing files, you could get the Notify404 plugin (which I wrote) which will send you an email if MODX serves a 404 error. (everything: so prepare for loads of emails) so you could use something like Redirector to create redirects for the 404’s to the new site.. Not ideal, but certainly functional. smiley
            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.