We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13730
    • 149 Posts
    I have two domains each running of is own Modx (2.2.0) instance on my account.

    domain1.com on the root
    domain2.com pointing to domain2.com subdirectory.

    domain2.com was created via the «Addon domain» of my CPanel Interface.

    How should I configure the .htaccess file of the subdirectory «domain2.com» to obtain URL with the name of domain2.com only, functional friendly URLs, and a manager who does not appear as text?

    And do I have to configure other files ?

    Here's what I tried :

    Case 1
    With no htaccess file in the domain2.com subdirectory
    Result :
    - When I enter www.domain2.com in the URL bar, it goes to the website of domain2, but the URL address change to http://.www.domain1.com/domain2.com/

    Case 2
    I use theses rules in the htaccess file of the domain2.com subdirectory

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

    Result :
    - When I enter « www.domain2.com » in the URL bar, it goes to home page of the website of domain2 and the URL address is « www.domain2.com », but the content of the home page is display as Text.

    - If a click on a link on the home page to go to an another page, the address of this page in the URL bar becomes « http://www.domain2.com/domain2.com/index.php?id=5 »,
    and only the content of my chunk is dispaly (I use two chunks in my template, one for my top menu and one for my footer menu) the other content in «[[*content]]» is not display.

    - The manager is display as Text

    I hope I described my problem correctly, English is not my first language,

    Thank you for answering
    [ed. note: jber last edited this post 12 years, 3 months ago.]
    • I have two separate sites on my Bluehost account. One, sottwell.com, is the main domain on which the account is created. The other, baby-roo.com, is a friend's website (she makes custom baby carriers). In my CPanel, I set baby-roo.com as an addon domain; in the file system (both the CPanel file manager and FTP) it exists as .../public_html/babyroo/.

      The .htaccess file for it looks like this:
      RewriteEngine on
      
      RewriteCond %{HTTP_HOST} ^baby\-roo\.sottwell\.com$ [OR]
      RewriteCond %{HTTP_HOST} ^www\.baby\-roo\.sottwell\.com$
      RewriteRule ^/?$ "http\:\/\/baby\-roo\.com\/" [R=301,L]
      
      #Options +FollowSymlinks
      RewriteBase /
      
      # The Friendly URLs part
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
      
        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
        • 13730
        • 149 Posts
        First, it is extremely nice to have responded.

        My main domain is lean-tpm-gcf.com and my addon domain (idlean.com) was setup via the Cpanel in a subfolder named idlean.com (/public_html/idlean.com). The subfolder idlean.com was automatically by the Cpanel.

        I modified your .htaccess file and place it in the idlean.com addon subfolder.

        I got a a 500 Internal Server Error . I noted in the error message, that the server administrator email is written like this [email protected]

        First essay :

        RewriteEngine on
         
        RewriteCond %{HTTP_HOST} ^idlean\.lean-tpm-gcf\.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www\.idlean\.lean-tpm-gcf\.com$
        RewriteRule ^/?$ "http\:\/\/idlean\.com\/" [R=301,L]
         
        #Options +FollowSymlinks
        RewriteBase /
         
        # The Friendly URLs part
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1

        Second essay

        RewriteEngine on
         
        RewriteCond %{HTTP_HOST} ^idlean\.lean\-tpm\-gcf\.com$ [OR]
        RewriteCond %{HTTP_HOST} ^www\.idlean\.lean\-tpm\-gcf\.com$
        RewriteRule ^/?$ "http\:\/\/idlean\.com\/" [R=301,L]
         
        #Options +FollowSymlinks
        RewriteBase /
         
        # The Friendly URLs part
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php?q=$1
        • Try setting your RewriteBase/ to the sub-folder. I was/am under the impression it needs to be set for sub-domains to work correctly. No? (Susan's post and example confuses me, unfortunately)


          RewriteBase /idlean


            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • I have had 500 errors from having the "RewriteEngine on" line duplicated if it's already set in the root level's .htaccess file; it's worth a try seeing if it works without it.

            Also, comment out or delete those first three condition/rule lines; I set them up because the add-on domain could be reached with those URLs. Your installation also may require the FollowSymlinks directive; every server seems to be configured differently!

            The email will be sent to your main domain's email address, since that's the owner of the actual hosting account.
              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
              • 13730
              • 149 Posts
              I make progress with this :

              RewriteCond %{HTTP_HOST} ^idlean\.lean\-tpm\-gcf\.com$ [OR]
              RewriteCond %{HTTP_HOST} ^www\.idlean\.lean\-tpm\-gcf\.com$
              RewriteRule ^/?$ "http\:\/\/idlean\.com\/" [R=301,L]
               
              #Options +FollowSymlinks
              RewriteBase /
               
              # The Friendly URLs part
              RewriteCond %{REQUEST_FILENAME} !-f
              RewriteCond %{REQUEST_FILENAME} !-d
              RewriteRule ^(.*)$ index.php?q=$1 


              When I type « www.idlean.com » I don't have the « lean-tpm-gcf.com » in the URL, but only the home is showing in text mode.

              So I check all my links and they was written like this : http://www.idlean.com/idlean.com/index.php?id=5.

              I verify the «base tag » of my templates and it was like this : <base href="[[!++site_url]]" />

              I change it to <base href="/" /> and hurrah! I can get all my pages correctly display without the Friendly URls, thanks to you.


              The only thing that is not working is the Friendly URLs part. The URL is well written in the URL bar, but when I click on a link I got a 404 page

              I try with no RewriteBase and with
              RewriteBase /
              RewriteBase /idlean
              RewriteBase /idlean.com

              I always got 404 page with is message :

              The requested URL /a-propos-de-nous/valeur-ajoutee.html was not found on this server.
              Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


              [ed. note: jber last edited this post 12 years, 3 months ago.]
                • 38525
                • 26 Posts
                Hi jber,

                I am currently struggling with my .htaccess too (trying to get friendly URL's to work with multiple domains). I faced the same problem you have now a few days ago, and this worked for me:

                Try adding this rule right after "RewriteBase /" in the (original) .htaccess file in your root:

                RewriteRule ^(domain2)($|/) - [L]

                This excludes the subfolder of domain2 from all the other rewrite rules, and the subfolder can also have it's own .htaccess now...

                You can also exclude more folders by adding them like this:

                RewriteRule ^(domain2|domain3|domain4)($|/) - [L]

                Hope this works!
                  • 7327
                  • 195 Posts
                  @suikerzout - great find mate! Was struggling with a newly added domain doing the funky "redirects" until support told me there was something in the htaccess file doing it. And I had another MODX installation in my primary domain. I think it'll be useful if the mods added this line to the default htaccess file with the appropriate comments for MODX users thinking about doing Addon Domains.