We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 43024
    • 5 Posts
    Hi,
    I have almost finish my next website based on Modx and I have one problem.

    This is two-languages site with pl/en translation. I used Babel Extras for translation and from tutorial I added two contexts (Polish, English) Set everything and also added in .htaccess

    # The Friendly URLs part
    # detect language when requesting the root (/)
    #RewriteCond %{HTTP:Accept-Language} !^en [NC]
    RewriteRule ^pl?/$ pl/mapa/ [R=301,L]
    RewriteRule ^en?/$ en/map/ [R=301,L]
    
    # redirect all requests to /en/favicon.ico and /de/favicon.ico
    # to /favicon.ico
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(pl|en)/favicon.ico$ favicon.ico [L,QSA]
    
    # redirect all requests to /en/assets* and /de/assets* to /assets*
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(pl|en)/assets(.*)$ assets$2 [L,QSA]
    
    # redirect all other requests to /en/* and /de/*
    # to index.php and set the cultureKey parameter
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(pl|en)?/?(.*)$ index.php?cultureKey=$1&q=$2 [L,QSA]
    


    All correct urls are working but also I want to handle wrong urls and redirect them to Error 404 page. But with thesse settings Page Error 404 works only when I'm trying url without pl or en i.e.
    /qwerty -> redirect to 404 Page
    /asdf -> redirect to 404 Page

    but this:
    /plqwerty -> redirect to blank 503 Error Page not found
    /enasdf -> redirect to blank 503 Error Page not found


    How I should change htaccess to redirect all wrong urls to Error 404 Page?

    Thanks.

      • 3749
      • 24,544 Posts
      You might try a plugin attached to OnPageNotFound:

      $modx->sendErrorPage();


      I'm not sure if it would work.
        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
        • 43024
        • 5 Posts
        Quote from: BobRay at Apr 20, 2015, 08:42 PM
        You might try a plugin attached to OnPageNotFound:

        $modx->sendErrorPage();


        I'm not sure if it would work.

        With this plugin I get Internal Server Error

        I guess it's problem with htaccess but I don't know how to set this to redirect /plqwertiufs to Error Page but /pl/mapa/ to correct page

        I forgot to put link to site, sorry http://edbochnak.pl/