We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5689
    • 289 Posts
    I made my church’s new site "live" today, and the links aren’t working properly.

    The actually file location relative to the root is something like /modx, but it is accessed in the browser at just the /

    I’m using mod_rewrite to redirect everything in the root to the modx subfolder, but modx thinks the site_url includes the modx subfolder, and it shouldn’t.

    I’m not sure if that was clear, but does anybody have any ideas?

    Thanks!
      I'm learning more about MODx all the time and loving it.
      • 3749
      • 24,544 Posts
      Have you run an upgrade install since you changed the rewrite rules? That might fix it.

      Back up the site first, and make sure you uncheck the sample site and snippet options when you install.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 7231
        • 4,205 Posts
        the site_url is set dynamically. If the site_url is not reflecting the correct URL you should try to clear the cache.

        Another idea is to run the installer in update mode after moving the site to its new location, this will clear the cached settings as well as rewrite the paths accordingly. I regularly run the installer after moving a site just as a precaution.

        If you are using the <base> tag you can always enter the URL manually:
        <base href="http://www.yourDomain.com/modx/" />


        Do you have the htaccess file setup to use the /modx subfolder? This is set in the top section where it says:

        Options +FollowSymlinks
        RewriteEngine On
        RewriteBase /


        To use the modx subfolder it should read:
        RewriteBase /modx

          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don&#39;t know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 5689
          • 289 Posts
          Yeah, I’ve tried that a couple times with no luck.

          Even running the installer, the URL is right. The install folder is right in the base of the site. But once I go to the manager, it starts adding the subfolder to the URL, and it also adds the subfolder to all of my links with Wayfinder and so forth. I put an echo() in config.inc.php, and $base_url is being set to include the subfolder, which means site_url includes the subfolder.

          dev_cw, I believe you’re explaining the opposite of what I need. tongue I don’t want the subfolder to show up anywhere. I have silent rewrites using mod_rewrite to redirect all calls from the root folder to the subfolder. "modx" should never appear in any URL, and all of my base URLs should be just "/".
            I&#39;m learning more about MODx all the time and loving it.
            • 3749
            • 24,544 Posts
            What is $base_url set to in the index.php file in the MODx root directory?
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 5689
              • 289 Posts
              It’s set to nothing, just empty quotes. I tried putting some different values in it, but none of them make anything different.
                I&#39;m learning more about MODx all the time and loving it.
                • 3749
                • 24,544 Posts
                Have you tried this in your template? (Be sure to clear the site and browser caches):

                <base href="http://www.yourDomain.com/" />
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 5689
                  • 289 Posts
                  Mhm, I’ve tried that as well, but Wayfinder is still using the site_url, so all of my menu links are a no go.

                  The manager seems to be fine now that I setup its .htaccess file, so it’s really just the automatically generated site_url that’s being a problem here. I’ve been fooling around with config.inc.php and looking at how it determines the site_url, and I don’t think there’s a way to make it work right without hardcoding what I need.

                  If I add this right before it defines the five constants in the middle of the file, then it all works right.
                  $site_url = 'http://www.example.com/';
                  $base_url = '/';
                  [\code]
                  
                  However, I'd really, really like not to have to hardcode anything.
                    I&#39;m learning more about MODx all the time and loving it.
                    • 53654
                    • 1 Posts
                    Create a php file - siteHostnames.php - in base_path/assets/cache i.e {modx_base_directory}/assets/cache. And put the put the following content in the file:

                    <?php
                    
                        define('MODX_SITE_HOSTNAMES',  'www.example.com,www.example2.com');
                    
                    


                    It allows the specification of more than one hostname as a comma separated list. Of course, you are free to specify just one hostname without any commas.


                    Note: The hostnames should not contain the protocol or any path. E.g https://www.example.com and www.example.com/home are both invalid