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

    I am using MODX for my main site, but as the hosting offers unlimited add-ons domains I have installed two other MODxs inside their respective directories.

    My site is
    [tt]./ The main site
    ./assets "
    ./manager "
    /domain1 A new domain with MODX
    /domain1/assets
    /domain1/manager
    /domain2 The second domain with MODX
    /domain2/assets
    /domain2/manager[/tt]


    I am trying to use Friendly URLs in all of them. So far its only working for the main site...

    In the .htaccess located in the / level the relevant content is

    [tt]Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /

    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} ^maindomain\.com [NC]
    RewriteRule ^(.*) http://www.maindomain.com/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} ^domain1\.com\.ar [NC]
    RewriteRule (.*) http://www.domain1.com.ar/$2 [R=301,L]

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} ^domain2\.com\.ar [NC]
    RewriteRule (.*) http://www.domain2.com.ar/$2 [R=301,L]

    # The Friendly URLs part
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{HTTP_HOST} !^domain1\.com\.ar [NC]
    RewriteCond %{HTTP_HOST} !^www\.domain1\.com\.ar [NC]
    RewriteCond %{HTTP_HOST} !^domain2\.com\.ar [NC]
    RewriteCond %{HTTP_HOST} !^www\.domain2\.com\.ar [NC]
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    [/tt]

    And the configuration in the manager is (for all sites)
    Use friendly URLS, yes
    prefix, none (blank)
    suffix, .html
    use friendly aliases, yes
    use friendly alias path, no
    allow duplicate aliases, no
    automatically generate aliases, no (all pages have aliases still)


    The .htaccess in the domain1 has
    [tt]#Options +FollowSymlinks
    #RewriteEngine On
    RewriteBase /domain1/

    # Fix Apache internal dummy connections from breaking [(site_url)] cache
    RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
    RewriteRule .* - [F,L]

    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^www\.domain1\.com\.ar [NC]
    RewriteRule (.*) http://www.domain1.com.ar/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?q=$1 [L,QSA][/tt]


    (Second site configuration is equal).

    Like I said, the mainsite works perfectly. All links nice and everything looks fine.
    The domain1 and domain2 sites works only for the main page (though it looks like .htaccess is not properly working, since if I enter domain1.com.ar instead of www.domain1.com.ar the page loads, but with no "www." completion).

    On this site when I try to access to any of the links, I get a 404 error.

    Any thoughts on this?? Is it possible to do nested installs of MODx or I am just loosing my time?

    Thanks a lot!
    Juan
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You don’t need to edit the rewrite rules in the respective .htaccess files; just add the subdirectory to the RewriteBase for each one:
      RewriteBase /domain1
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 8771
        • 2 Posts
        Hi, thanks for the answer.

        What I did was to restore the .htaccess of the domain1 (first subdomain) to almost its original state. I just commented the RewriteEngine on line because it was causing 500 errors:

        [tt](.htaccess inside /domain1 subdirectory)
        RewriteBase /domain1 Removed the backslash here

        RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
        RewriteRule .* - [F,L]

        RewriteCond %{HTTP_HOST} !^www\.domain1\.com\.ar [NC] Using the classic it’s not equal condition
        RewriteRule (.*) http://www.domain.com.ar/$1 [R=301,L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA][/tt]


        And for the main .htaccess in the main site I did some changes (in respect of the original ht.access file)

        [tt]Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /

        RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]
        RewriteRule .* - [F,L]

        RewriteCond %{HTTP_HOST} .
        RewriteCond %{HTTP_HOST} ^mainsite\.com [NC] Using a different "is equal" condition
        RewriteRule (.*) http://www.mainsite.com/$1 [R=301,L]

        RewriteCond %{HTTP_HOST} .
        RewriteCond %{HTTP_HOST} ^domain1\.com\.ar [NC]
        RewriteRule (.*) http://www.domain1.com.ar/$1 [R=301,L]


        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        [tt]#RewriteCond %{HTTP_HOST} !^bodegasdelcielo\.com\.ar [NC] Commented this two lines
        #RewriteCond %{HTTP_HOST} !^www\.bodegasdelcielo\.com\.ar [NC]
        [/tt]
        RewriteRule ^(.*)$ index.php?q=$1 [L,QSA][/tt]


        So far I couldn’t improve the situation. The nice ulrs work just fine for www.mainsite.com but they don’t for www.domain1.com.ar site. I can write http://domain1.com.ar (without www) and will access the page without adding it, and all the subpages will give 404 errors.

        Any further advise will be welcomed!!
        best,
        Juan