We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6179
    • 4 Posts
    Dumb question, but I can’t seem to find an answer. Perhaps I’m phrasing it incorrectly.

    The page I want is at "mydomain.com/modx/" and all of the content is in a template.

    How do I get this page on to my top domain so that when "mydomain.com" is called, it goes straight to that page.

    I’m thinking I could redirect my domain to "/modx", but there has to be an easier way. Do I need to move the modx installation to the top domain "mysite.com/"?

    Where should I look?

    Thanks for your input.

    -Chase
      • 6228
      • 249 Posts
      Did you ever resolve this?

      One simple way would be to locate and open the htaccess file in your root directory, and change the last RedirectRule like so:

      from this
      RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

      to this
      RewriteRule ^(.*)$ http://your-domain.com/modx/index.php?q=$1 [L,QSA]
        lo9on.com

        MODx Evolution/Revolution | Remote Desktop Training | Development
        • 6179
        • 4 Posts
        Thanks for the response. I’ve tried playing with it to no avail. I’ve been using a site redirect through my host in the mean time. Perhaps you can tell me what I’m doing wrong. I’ve tried changing each instance one at a time, and all of them. Here’s what the .htaccess file looks like currently. How can I fix this mess?


        # MODx supports Friendly URLs via this .htaccess file. You must serve web
        # pages via Apache with mod_rewrite to use this functionality, and you must
        # change the file name from ht.access to .htaccess.
        #
        # Make sure RewriteBase points to the directory where you installed MODx.
        # E.g., "/modx" if your installation is in a "modx" subdirectory.
        #
        # You may choose to make your URLs non-case-sensitive by adding a NC directive
        # to your rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA,NC]
        
        RewriteEngine On
        RewriteBase /
        
        
        
        # Rewrite www.domain.com -> domain.com -- used with SEO Strict URLs plugin
        #RewriteCond %{HTTP_HOST} .
        #RewriteCond %{HTTP_HOST} !^www\.chasenow\.co.uk [NC]
        #RewriteRule ^(.*)$ http://chasenow.co.uk/modx/ [L,QSA]
        #
        # or for the opposite domain.com -> www.domain.com use the following
        # DO NOT USE BOTH
        #
        #RewriteCond %{HTTP_HOST} .
        #RewriteCond %{HTTP_HOST} !^www\.chasenow\.co.uk [NC]
        #RewriteRule ^(.*)$ http://chasenow.co.uk/modx/ [R=301,L]
        
        
        
        # Rewrite secure requests properly to prevent SSL cert warnings, e.g. prevent 
        # https://www.domain.com when your cert only allows https://secure.domain.com
        #RewriteCond %{SERVER_PORT} !^443
        #RewriteRule (.*) https://example-domain-please-change.com.com/$1 [R=301,L]
        
        
        
        # The Friendly URLs part
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ http://chasenow.co.uk/modx/ [L,QSA]
        
        
        
        # Make sure .htc files are served with the proper MIME type, which is critical # for XP SP2. Un-comment if your host allows htaccess MIME type overrides.
        
        #AddType text/x-component .htc
        
        
        
        # If your server is not already configured as such, the following directive
        # should be uncommented in order to set PHP's register_globals option to OFF.
        # This closes a major security hole that is abused by most XSS (cross-site
        # scripting) attacks. For more information: http://php.net/register_globals
        #
        # To verify that this option has been set to OFF, open the Manager and choose
        # Reports -> System Info and then click the phpinfo() link. Do a Find on Page
        # for "register_globals". The Local Value should be OFF. If the Master Value
        # is OFF then you do not need this directive here.
        #
        # IF REGISTER_GLOBALS DIRECTIVE CAUSES 500 INTERNAL SERVER ERRORS :
        #
        # Your server does not allow PHP directives to be set via .htaccess. In that
        # case you must make this change in your php.ini file instead. If you are
        # using a commercial web host, contact the administrators for assistance in
        # doing this. Not all servers allow local php.ini files, and they should
        # include all PHP configurations (not just this one), or you will effectively
        # reset everything to PHP defaults. Consult www.php.net for more detailed
        # information about setting PHP directives.
        
        #php_flag register_globals Off
        
        
        
        # For servers that support output compression, you should pick up a bit of
        # speed by un-commenting the following lines.
        
        #php_flag zlib.output_compression On
        #php_value zlib.output_compression_level 5
        
        
        
        # The following directives stop screen flicker in IE on CSS rollovers. If
        # needed, un-comment the following rules. When they're in place, you may have
        # to do a force-refresh in order to see changes in your designs.
        
        #ExpiresActive On
        #ExpiresByType image/gif A2592000
        #ExpiresByType image/jpeg A2592000
        #ExpiresByType image/png A2592000
        #BrowserMatch "MSIE" brokenvary=1
        #BrowserMatch "Mozilla/4.[0-9]{2}" brokenvary=1
        #BrowserMatch "Opera" !brokenvary
        #SetEnvIf brokenvary 1 force-no-vary


        -Thanks
          • 6228
          • 249 Posts
          Well it appears as though you’re missing the query string at the end of this line:
          RewriteRule ^(.*)$ http://chasenow.co.uk/modx/ [L,QSA]

          which should look like this:
          RewriteRule ^(.*)$ http://chasenow.co.uk/modx/index.php?q=$1 [L,QSA]


          ... although I’m not entirely sure if it will make a difference. Worth trying though. Let us know.

          Mike
            lo9on.com

            MODx Evolution/Revolution | Remote Desktop Training | Development
            • 26384
            • 3 Posts
            SchwingBlade Reply #5, 16 years ago
            I’m here with the same exact question, after 2 days of searching.

            I never would have installed MODx 2.0 into a subdir in the first place, except for warnings about unspecified security concerns when installing into the root.

            The suggestion to rewrite the URL using .htaccess just doesn’t...feel...right. That’s backwards, isn’t it? MODx just needs to shift gears and create pages in another directory, right? I mean, when you move, you don’t expect the Post Office to forward your mail from the wrong address to the right one for all eternity...you know the new address, so you just start using it.

            With all of the SEO and performance concerns surrounding redirects, as well as the potential .htaccess pitfalls such as loops, chains, and RegEx errors...isn’t it reasonable to expect that MODx might know where it is in relationship to the server root, and handle its own paths accordingly?
              • 36493
              • 64 Posts
              Hi I believe that the rewriterule should be this:
              RewriteRule ^(.*)$ modx/index.php?q=$1 [L,QSA]


              Its only matching from the rewritebase "/"

              In terms of installing modx in to a different directory(for security) this is to install the working files ’core’ etc behind root(non http visible) then put your index.php and config.core.php where ever you want eg. in the root (making sure you set the path to core in the config.core.php)

              cheers,
                |
                • 6228
                • 249 Posts
                Quote from: SchwingBlade at Sep 22, 2010, 08:50 PM

                The suggestion to rewrite the URL using .htaccess just doesn’t...feel...right. That’s backwards, isn’t it? MODx just needs to shift gears and create pages in another directory, right? I mean, when you move, you don’t expect the Post Office to forward your mail from the wrong address to the right one for all eternity...you know the new address, so you just start using it.

                With all of the SEO and performance concerns surrounding redirects, as well as the potential .htaccess pitfalls such as loops, chains, and RegEx errors...isn’t it reasonable to expect that MODx might know where it is in relationship to the server root, and handle its own paths accordingly?

                Revo makes it possible to easily migrate the core directory to anywhere within the server filesystem - but the collateral directories (assets, manager, connectors, etc.) should remain in the web root. The intention is to only allow direct script access to the core directory by moving it outside the web root (as well as potentially changing the core folder name to obfuscate it).

                I wouldn’t know how MODx would be able to guess the location of a relocated core directory. Hardcoding the path in config files, though, isn’t a terrible inconvenience, and in fact kind of gives me peace of mind that the path will always be correct and hackable-less by a tainted server variable or something other.
                  lo9on.com

                  MODx Evolution/Revolution | Remote Desktop Training | Development
                  • 12241
                  • 80 Posts
                  It seems we are missing the point of the original question (or I’m missing the point of this thread smiley):
                  how can modx be installed in a subdirectory without that subdirectory displaying in the URL of the browser ie top level domain only.

                  Modx is installed in www.top-level-domain.com/subdirectory/
                  The goal is to access modx via www.top-level-domain.com
                  AND to never display the subdirectory that modx is installed in, so all URL’s appear to be coming from root directory eg www.top-level-domain.com/index.php?id=1 would normally look like www.top-level-domain.com/subdirectory/index.php?id=1

                  Here is .htaccess code I’m using to hide the subfolder from the URL:
                  #htaccess file located in root folder
                  RewriteEngine On
                  RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
                  RewriteCond %{REQUEST_URI} !^/subdirectory/
                  RewriteRule ^(.*)$ subdirectory/$1 [L] 
                  

                  found here:
                  http://forums.site5.com/showpost.php?p=143837&postcount=4

                  This works for the front end of the site perfectly (as long as the site_url settings are set correctly in ’web’ context ie no subdirectory in the paths), [b]the only problem (so far) I’m facing is that the manager login page will just refresh itself upon logging in.[/b] undecided It gives no error, just a refresh. Is there a setting for the manager context or in the config.core.php file that can get the manager to cooperate? I’m having a difficult time isolating the problem but it does seem to fix it self after disabling this rewrite rule from the .htaccess file which does not make sense to me because this htaccess file is in web root and the rest of modx is installed in /subfolder/.

                  huh Does anyone have an idea how to get the manager to login correctly with this configuration? (and if it matters I have only tested this in my localhost environment.)

                    Environment:
                    modx: rev 2.0.8-pl
                    localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Does it matter what URL the manager uses? You can put a .htaccess file in the manager directory to turn off the rewrite engine, which should be done anyway.
                      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
                      • 12241
                      • 80 Posts
                      the default .htaccess file in the /manager/ folder is enabled with the rewrite rules turned off for that directory.

                      I go to www.top-level-domain.com/manager and when I log in the page is refreshed with www.top-level-domain.com/subdirectory/manager. From there it just refreshes the page upon logging in.

                      Is there a way I can move the manager folder out of the subdirectory into root while leaving the rest of modx in the subdirectory?
                        Environment:
                        modx: rev 2.0.8-pl
                        localhost: Apache/2.0.63 (Unix) PHP/5.2.11 DAV/2, MySQL client version: 5.1.37