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

    Whenever I enter a URL that's not found on the site, the home page loads but the page URL remains what I entered. For example, if I try to go to www.sitename.com/fubar.html, which doesn't exist, it will display the homepage for www.sitename.com, and the URL will point to www.sitename.com/fubar.html.

    How can I correct this? I'm also trying to configure it so that unauthorized access to certain resource groups will redirect to an error page. Currently, this also redirects users in the same way as for pages that aren't found.

    Any suggestions would be greatly appreciated.

    Andrew

    This question has been answered by multiple community members. See the first response.

    • discuss.answer
      • 3109 ☆ A M B ☆
      • 894 Posts
      Make a new resource for your 404 page then go to system settings and filter by site and enter the resource id in the 404 error page entry.

      That should take care of it.
        Benjamin Marte
        Interactive Media Developer
        Follow Me on Twitter | Visit my site | Learn MODX
        • 36752
        • 27 Posts
        Thank you!

        One more thing though... I don't suppose it's possible to have different error pages for different resource groups? Or a different error page for "Page not found" versus "Access Denied"?
        • discuss.answer
          • 3109 ☆ A M B ☆
          • 894 Posts
          Same thing you did for the 404 page can be done for:


          • Site Unavailable Page
          • Unauthorized Page
            Benjamin Marte
            Interactive Media Developer
            Follow Me on Twitter | Visit my site | Learn MODX
            • 3749
            • 24,544 Posts
            Yes, that's definitely possible. I'm assuming that you're using Revolution.

            There are two System Events: OnPageNotFound and OnPageUnauthorized. A plugin connected to either event should be able to check the resource group of the current resource and forward the user anywhere you want.

            Making the unauthorized page work is tricky in Revo, because trying to access an unauthorized page actually triggers OnPageNotFound by default. There's a section here ("Unauthorized versus Error Page") on how to get around that: http://bobsguides.com/revolution-permissions.html


            The plugin code for resource group detection might look something like this:

            <?php
            $docId = $modx->resource->get('id');
            $groupId = '12'; // ID of the resource group
            $myNotFoundPage = '33'; // ID of specific "not found" page
            $url = $modx->makeUrl($myNotFoundPage,'','','full');
            
            if ($modx->getObject('modResourceGroupResource', array('document_group'=>$groupId, 'document'=>$docId))  ) {
                /* resource is in group */
                $modx->sendRedirect($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