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

    Although I don’t fully understand what is going on in the background with friendly URLs, I’ve managed to follow the instructions on the wiki/forums etc and had them working great with our old host as well as locally using MAMP.

    On the new host’s servers, friendly URLs seems to be working as the URLs are being rewritten but no page is diplayed - so I guess something’s not right.

    Our new host requires a slightly different tweak to the .htaccess file than the last host and I wonder if it is causing issues with Modx? Here is what they suggest:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /index.php?id=$1 [L,QSA]


    Note the / before index.php - my last .htaccess file just had index.php?...

    Something else that is differnet is that when previewing our site the URL isn’t: sitename.hostname.com as it was with the last host.
    But is: hostname.com/sitename/

    Not sure if that matters though!


    I also have a configuration error in Manager:
    Configuration warning: ’register_globals is set to ON in your php.ini configuration file’

    I’ve checked the settings on our account and the host has done the same thing and we both agrree it is set to off. However, the host thinks Modx is look at the master php.ini for their whole hosting cluster as opposed to the one in our account - does this make sense? Not sure if this has any effect on the friendly urls but thought I’d mention it just incase.

    Any help would be much appreciated.

    Cheers

    Ben

    PS made a donation to Modx today, if you haven’t already, you can do so here: http://modxcms.com/community/donate.html
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Try putting some garbage at the front of the .htaccess file and saving it temporarily... when you visit your site, you should get a server error. If you don’t, then it means your .htaccess file is not being parsed. Can you verify this behavior?

      Also, you have to do some tweaks if you have MODx in a sub-directory. Where is your .htaccess file? is it at the root of the site? Or is it in that sub-directory?

      Regarding the leading slash for index.php, try omitting it and see what happens.

      If register_globals is on... yuck.
        • 5532
        • 251 Posts
        Hey Everett, thanks for the reply.

        I put garbage at the start and got an "Internal Server Error" instead so I guess the .htaccess file is being parsed.

        I tried your suggestions one-by-one but I just got "Not Found" errors.

        The .htaccess file is currently in the top level of my Modx installation - where the index.php file resides. Is this what you mean by root directory or do you mean the root directory for our entire hosting account? Anyway, I tried that but it didn’t work either.

        The weird thing for me is that the URLs are correct, there is just no page being displayed.

        If register_globals is on... yuck
        What exactly does this mean?
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          Ok, so you’re .htaccess file is being parsed. That’s good. The next thing I would try is just making sure you can hit a static file in your site root. E.g. create a temporary file named "test.txt" that contains something like "Hello", and see if you can navigate to http://yourdomain.com/test.txt -- you should see "Hello". That’ll just let me know that your domain name is mapped appropriately. You said before that your root is actually in a sub-directory, so you might actually navigate to http://yourdomain.com/xxx/test.txt -- is that correct? And can you verify where you put your .htaccess file? In that subdirectory alongside the test.txt file?

          register_globals... sigh... stupid PHP stuff. In short, if globals are on, then your site’s security is at risk.
            • 5532
            • 251 Posts
            Hey Everett,

            I found this exmaple htaccess file on the new Modx SVN help and once I put my site’s directory in after "RewriteBase /" it worked.
            # For full documentation and other suggested options, please see  
            # http://svn.modxcms.com/docs/display/MODx096/Friendly+URL+Solutions  
            # including for unexpected logouts in multi-server/cloud environments  
              
            Options +FollowSymlinks  
            RewriteEngine On  
            RewriteBase /myWebsiteDirectory
              
            # Fix Apache internal dummy connections from breaking [(site_url)] cache  
            RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]  
            RewriteRule .* - [F,L]  
              
            # Rewrite domain.com -> www.domain.com -- used with SEO Strict URLs plugin  
            #RewriteCond %{HTTP_HOST} .  
            #RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]  
            #RewriteRule (.*) http://www.example.com/$1 [R=301,L]  
              
            # Exclude /assets and /manager directories from rewrite rules  
            RewriteRule ^(manager|assets) - [L]  
              
            # For Friendly URLs  
            RewriteCond %{REQUEST_FILENAME} !-f  
            RewriteCond %{REQUEST_FILENAME} !-d  
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]  
              
            # Reduce server overhead by enabling output compression if supported.  
            php_flag zlib.output_compression On  
            php_value zlib.output_compression_level 5


            Just one thing, if I use a link like "/home" it doesn’t work because it strips off the folder where the development site resides like this:
            Normal home URL
            http://developmentserver.com/mysitefolder/home

            Using a "/home URL"
            http://developmentserver.com/home


            I’ve only done this on the logo for the site in the header, is there’s a more elegant solution that will get Modx to always insert the home page ID instead of hard coding the home page URL - does that makes sense?

            register_globals... sigh... stupid PHP stuff. In short, if globals are on, then your site’s security is at risk.
            My Host assures me that because it is off for our hosting account it doesn’t matter - is this correct or because the host has it on for their servers it could effect everyone?

            Cheers

            Ben