We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46463
    • 8 Posts
    Tearing my hair out over this. It seems I have things partially working, but I must have missed something along the way. I know there are many threads on the subject, but didn't see one specific to this, and most are pretty dated.

    Before touching friendly URLs, the path to access my pages was, e.g.: http://mydomain.com/modx/index.php?id=2

    Now I can access my pages from e.g.: http://www.mydomain.com/mypagealias.html

    So that's a good thing.

    However when clicking "view" from any Resource, it launches the page with a URL of e.g.: http://www.mydomain.com/modx/mypagealias.html. And the Wayfinder links do the same thing. And the manager still loads at http://www.mydomain.com/modx/manager. And the manager now prompts me to re-login frequently.

    Details:

    - MODX was installed in the www/modx subdirectory on my web server
    - followed this guide: http://rtfm.modx.com/revolution/2.x/administering-your-site/using-friendly-urls
    - consolidated the MODX htaccess lines underneath my web host's htaccess in the root (www) directory. Did not activate an htaccess file in the /modx subdirectory
    - in the active htaccess file, set the RewriteBase line to
    RewriteBase /modx/

    - turned on these lines in htaccess:

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


    Any input would be appreciated!

    This question has been answered by lankford. See the first response.

      • 44580
      • 189 Posts
      Assuming you're using Apache, I think you need to create an entry for your domain in "sites-available". You should be able to get a sense of what you need from here: http://codingpad.maryspad.com/2012/03/14/how-to-create-multiple-virtual-hosts-in-ubuntu/

      However I think that will require you to move your htaccess file back to the modx directory (and change RewriteBase). I'm no expert, but that's pretty much what I did to get what you want.
        • 3749
        • 24,544 Posts
        Try this:

        RewriteBase /


        On many servers you can have the site in a subdirectory without changing the default RewriteBase code.

        Also, make sure you have this in the head section of all templates:

        <base href="[[!++site_url]]" />


          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
          • 46463
          • 8 Posts
          When I change to...
          RewriteBase /
          ...a) the manager still launches pages to http://www.mydomain.com/modx/mypagealias.html, and b) I get a 404 error: The requested URL /index.php was not found on this server. Note I get that same error whether I hard-enter http://www.mydomain.com/modx/mypagealias.html OR http://www.mydomain.com/mypagealias.html

          I've consistently had
          <base href="[[!++site_url]]" />
          at the very bottom of my head for the templates (it is included from a chunk).

          I do not see where I can get at Apache files (this is a new host for me), although my cPanel does indicate the site is running Apache 2.2.27. I can reach out to my host tomorrow if gissirob's suggestion is the direction I need to go.

          Other suggestions? Appreciate the quick responses
            • 3749
            • 24,544 Posts
            Normally, if 'modx/' is not in the .htaccess file anywhere and you don't enter it in the original URL, it would be impossible for MODX to ever send you to a URL with modx/ in it. MODX creates the site_url setting on the fly based on the URL the user comes in on. All URLs used in MODX are based on that.

            Did you delete all files in the core/cache directory after making the change to .htaccess?

            If you can get into the database in cPanel, you might check the path in the first entry (it should be the only entry) of the modx_workspaces_table.

            Being logged out of the Manager is almost always a sign that the www/non-www code isn't working. When a user switches from a www URL page to a non-www URL page (or vice versa), the session is lost and you have to log in again.

            It's rare, but some hosts have set the server so that .htaccess is completely ignored in a user directory and has no effect.

            You might also check to see if there is another .htaccess file above the MODX root that might be affecting things.

            If you set up a 'virtual' host or domain redirect in cPanel involving the 'modx/' directory, that might also explain the problem.

            You did run Setup after moving the site from the subdirectory to the root, right?

              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
              • 46463
              • 8 Posts
              Still struggling with this.

              What happens now is, if I have "RewriteBase /modx/" in htaccess, the manager launches all pages, and FURLs work, but always with a mydomain/modx/mypagealias.html format

              If I have "RewriteBase /" in htaccess, the homepage of the site launches at mydomain.com/modx, but none of the other pages launch, whether /modx is included or not! I get "The requested URL /index.php was not found on this server."


              You did run Setup after moving the site from the subdirectory to the root, right?

              Want to make sure I was clear. My MODX install is in the /modx subdirectory off my www root, but I am looking for the /modx to be eliminated from all URL paths. I did rerun Setup after following the FURL guide, but I do not think I actually "moved the site". Did I miss something?

              Did you delete all files in the core/cache directory after making the change to .htaccess?

              Yes

              If you can get into the database in cPanel, you might check the path in the first entry (it should be the only entry) of the modx_workspaces_table.

              That field contains the following string: {core_path}

              It's rare, but some hosts have set the server so that .htaccess is completely ignored in a user directory and has no effect.

              What I described above about my RewriteBase findings would seem to imply that .htaccess is working, correct?

              Feeling totally lost at this point...
              [ed. note: lankford last edited this post 9 years, 9 months ago.]
                • 44580
                • 189 Posts
                There must be many sites like yours running out of a subdirectory and that does not have full access to the filesystem - so we must assume there is a way to do this. As I said before, the extra step I took was to add a "sites-available" entry to the apache config. Did I have to do this? I thought so because I am running multiple domains from one www root. Do you have to? I really don't know - but it makes logical sense to me. You want your domain to land in the subdirectory, not above it - and:
                < VirtualHost *:80 >
                  DocumentRoot /var/www/modx
                  ServerName www.mydomain.com
                  ServerAlias mydomain.com
                < /VirtualHost >

                does exactly that. Sorry I can't be of more help.

                Robert
                  • 46463
                  • 8 Posts
                  Robert - appreciate your follow-up. I've checked with my host and unfortunately they do not allow access to the apache config for shared hosting sites.

                  I've spent the last couple hours going back through the archives and the volume of posts on this topic going back 4+ years is just overwhelming...many permutations, lots of trial and error, but few answers...
                    • 44580
                    • 189 Posts
                    Yes, I've lost count of the hours trying to make sense of disparate forum posts.

                    I've never used cPanel, but something Bob said above got me thinking... this is from a cPanel forum: http://forums.cpanel.net/f442/documentroot-htttpd-conf-359282.html#post1450471. It might be irrelevant, it might not. At worst it is another forum to try and make sense of smiley
                      • 3749
                      • 24,544 Posts
                      I think I may have misunderstood you to say that you had moved the site from the subdirectory to the root. I thought you were trying to get rid of the 'modx' left over from before the move.

                      I am far from and expert on URL manipulation. Susan would almost certainly be more help.

                      Ironically, Bob's Guides is in a subdirectory. The Rewrite Base is definitely /.

                      My memory of how I did it is pretty dim, but I believe I used a domain-related tool in cPanel, which links bobsguides.com to the subdirectory. That tool may actually have created the virtual host gissirob is referring to.



                        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