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

    Does anyone know if can install MODx not at the root of web server (but for e.g. in TEST_1 directory) and configure the site address to for e.g. www.mydomain.com.

    Thanks and regards,
    Wayne.
      • 36502 ☆ A M B ☆
      • 491 Posts
      you can install MODx in a directory for sure,
      as regards the access from the main address you could use .htaccess to redirect your users,

      but I don't know if it may cause some conflicts with friendly url...

        TilliLab | MODX Ambassador
        website
        • 32013
        • 24 Posts
        Hi tillilab,

        Thank you for your reply. I am glad to know I can use the .htaccess for re direction.
        I am not sure if I did it correctly. My MODx was installed in www.mydomain.com/TEST_1, what I want to achieve is when people enter www.mydomain.com they will see the content in www.mydomain.com/TEST_1 but the URL on the web browser remains as www.mydomain.com


        Thanks and regards,
        Wayne.
          • 36502 ☆ A M B ☆
          • 491 Posts
          I think that you can do it with the htaccess directive RewriteRule instead of Redirect.

          I'm not expert of htaccess and Apache... but you can find a lot of resources online,
          best regards,
          Alessandro
            TilliLab | MODX Ambassador
            website
            • 32013
            • 24 Posts
            Hi Alessandro,

            Thank you again for your reply. I also consulted my web host admin. and I manage to achieve what I want with the below script in .htaccess. I am not sure if that script is generic or web host specific but it solve my problems smiley

            # .htaccess main domain to subdirectory redirect
            # Copy and paste the following code into the .htaccess file
            # in the public_html folder of your hosting account
            # make the changes to the file according to the instructions.
            # Do not change this line.
            RewriteEngine on
            # Change yourdomain.com to be your main domain.
            RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
            # Change 'subdirectory' to be the directory you will use for your main domain.
            RewriteCond %{REQUEST_URI} !^/subdirectory/
            # Don't change this line.
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            # Change 'subdirectory' to be the directory you will use for your main domain.
            RewriteRule ^(.*)$ /subdirectory/$1
            # Change yourdomain.com to be your main domain again.
            # Change 'subdirectory' to be the directory you will use for your main domain
            # followed by / then the main file for your site, index.php, index.html, etc.
            RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
            RewriteRule ^(/)?$ subdirectory/index.php [L]