We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9572
    • 56 Posts
    Just some background:

    I have Modx installed in a subdirectory of a site and I'm trying to give it it's own TLD and get rewrites working properly but I'm encountering some issues. Here's what I've done:


    • In Cpanel, I've added the domain name to the "Addon Domains" section and mapped it to the subdirectory that Modx is installed in.
    • I've renamed the included ht.access file to .htaccess and modified it to reflect the subdirectory that Modx is installed in.
    • I've cleared the cache from the manager

    What happens now is that when I try to navigate to any page other than the index, I get an internal server error (500) and when I try to access the manager, it includes the subdirectory name in the rewrite instead of removing it (which causes any relative links (such as images and stylesheets) to break.

    When I look at the URL that's being requested for images and stylesheets, it looks like this:

    http://domain.com/subdirectory/pagename.html
    


    Instead of:

    http://domain.com/pagename.html
    


    How do I get Modx to see that the site base URL is not a subdirectory? Currently the output of [[!++site_url]] is http://domain.com/subdirectory/ [ed. note: fegul last edited this post 13 years, 7 months ago.]
      • 9572
      • 56 Posts
      Here's what the htaccess looks like:

      RewriteEngine On
      RewriteBase /subdirectory
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      
        • 42562
        • 1,145 Posts
        With the new addon, www.domain.com, as far as MODx is concerned, or anybody for that matter, your new site exists by itself and not in a sub-directory. That's a secret between you and your server, that is, where your physical files are (www.main-mother-account.com/domain/)

        So MODx should be made to treat your site as a true TLD, hence just a slash will do. Don't include the sub-directory
        RewriteEngine On
        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

        If you wanted another MODx installation within your new domain, that is, www.domain.com/new-modx/ (physically located in www.main-mother-domain.com/domain/new-modx/) then you would need it in the .htaccess file. and don't forget, two slashes
        RewriteEngine On
        RewriteBase /new-modx/
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]



          TinymceWrapper: Complete back/frontend content solution.
          Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
          5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
          • 9572
          • 56 Posts
          That doesn't seem to be working either. I get a 403 forbidden error when trying to access the homepage so I can't really test it out.

          When I try to access it from another computer it works but the base url is still domain.com/subdirectory(I've cleared the cache on my own and still get a 403)
            • 9572
            • 56 Posts
            FYI, by manually setting the base url in the <head> tags to the TLD, I was able to get it to work. For some reason ModX doesn't seem to respect Cpanel's addon domain setting and continues to add the subdirectory automatically.

            Instead of this in the <head> tags:
            <base href="[[!++site_url]]" />

            I have:
            <base href="http://domainname.com/" />