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

    in Revo 2.2.3 the friendly_urls_strict system setting was introduced...

    - [#7933] Add friendly_urls_strict to optionally enable non-canonical redirects

    I wasn't able to find any explanation/tutorial in the rtfm. So my question is basically, what is it good for?

    Right now this is my setup:

    • friendly_urls enabled
    • friendly_urls_strict disabled
    • vhost.conf: domain.com -> www.domain.com enabled

    This leads to the following behavior:

    enter url -> result url

    example.com -> www.example.com
    example.com/test.html -> www.example.com/test.html
    example.com/test -> modx error 404 resource
    example.com/test/ -> modx error 404 resource



    My assumption was, when I enable friendly_urls_strict the output of the last two examples should change to

    example.com/test -> www.example.com/test.html
    example.com/test/ -> www.example.com/test.html



    But it doesn't. I can't see any difference to friendly_urls_strict disabled. Am I missing something here? [ed. note: paul_kemp last edited this post 14 years ago.]
      • 40385
      • 75 Posts
      I've to correct myself. I'm using a translated modx revo installation in which the description for the friendly_urls_strict system settings is missing.

      Here's the description in english:

      When friendly URLs are enabled, this option forces non-canonical requests that match a Resource to 301 redirect to the canonical URI for that Resource. WARNING: Do not enable if you use custom rewrite rules which do not match at least the beginning of the canonical URI. For example, a canonical URI of foo/ with custom rewrites for foo/bar.html would work, but attempts to rewrite bar/foo.html as foo/ would force a redirect to foo/ with this option enabled.';

      From my understanding friendly_urls_strict system setting allows these kind of redirects (example.com/test/ -> www.example.com/test.html) but they need to be specified in htaccess or .conf file. Is this correct?
        • 22303 MODX Staff
        • 10,725 Posts
        The following URI's would be valid if your Resource was a container (assuming container_suffix = / in your Settings):

        test/ (canonical)
        test => test/ (301 to canonical)

        These would be valid if your Resource was not a container, was of HTML content type, and your extension for HTML was set to .html:

        test.html (canonical)

        Any other variations you would need to handle using WebLinks or (as you suggested) custom rewrite rules for your web server.

        The only thing friendly_urls_strict does is, by being disabled by default, support MODX sites that were using custom rewrite rules to allow custom friendly URLs to be rewritten to a single Resource that did not match that Resource's URI. Changes to the canonical rewrites in MODX 2.2 originally caused a problem for users who were using this technique, and this setting enabled them to upgrade to 2.2 without changing their code.
          • 40385
          • 75 Posts
          Thanks for the explanation!!!