We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36747
    • 138 Posts
    I’m redesigning a MODx powered site (www.sabf.org.ar) and right now I can use the power of friendly URLs (there’s a topic alive about not being able to use this option, the solution was to get a new server smiley ).

    I’d love to know how friendly URLs are created, as I want to not show folders that are marked as "not show in menu" (I’m using Use friendly alias path) in the path.

    My site is in 2 languages: english and spanish, each one is a folder where i put inside all the pages and folders of the site. At the moment all the URLs are like this: www.sabf.org.ar/english/whatever-page.html and www.sabf.org.ar/espanol/cualquier-pagina.html. As the alias of the pages in each language are in those languages I don’t need (and I don’t want) to show "/english" and "/espanol" in the URL.

    This is why I’d love to know how friendly URLs are created to try to not show those folders.

    cheers
    eemi
      patagonia, argentina
      • 21257 MODX Staff
      • 730 Posts
      Quote from: eemi at Dec 13, 2007, 01:07 PM

      At the moment all the URLs are like this: www.sabf.org.ar/english/whatever-page.html and www.sabf.org.ar/espanol/cualquier-pagina.html. As the alias of the pages in each language are in those languages I don’t need (and I don’t want) to show "/english" and "/espanol" in the URL.

      eemi,
      Just to clarify, are you saying you’d like for the URLs you used as examples to be as follows instead?
      www.sabf.org.ar/whatever-page.html
      www.sabf.org.ar/cualquier-pagina.html
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 36747
        • 138 Posts
        Yes! But also

        • www.sabf.org.ar/el-foro/tema-central.html
        • www.sabf.org.ar/the-forum/central-topic.html

        That’s why I’m using Use friendly alias path On.

        The idea is to get rid of the /english and /espanol in the urls smiley
          patagonia, argentina
          • 21257 MODX Staff
          • 730 Posts
          There is no way to do this currently with MODx out-of-the-box. There are some potential collisions with naming that have ramifications pretty far into the core code.
          It could be acheived with a custom plugin, as long as care was taken not to create similar-named aliases in the two languages.
          For a simpler solution, if the only reason to have the /english and /espanol branches in the manager are to logically separate the content and neaten things up, I’d be tempted to give that up and just have the document tree the way you want the URLs. If there are other reasons to have those branches, such as inheriting values of template variables, then you’re faced with the more difficult task of writing a plugin.
            Mike Schell
            Lead Developer, MODX Cloud
            Email: [email protected]
            GitHub: https://github.com/netProphET/
            Twitter: @mkschell
            • 36747
            • 138 Posts
            Do you think is possible to do something with mod_rewrite to achieve my goal?
              patagonia, argentina
              • 21257 MODX Staff
              • 730 Posts
              I did think about that, but I don’t think there’s any elegant solution there. There’s no way* for mod_rewrite to take a URL like
              domain.com/doc1.html
              and turn it into
              domain.com/english/doc1.html or domain.com/espanol/doc1.html, how would it know which one is right, or if the document even belonged to one of those directories?

              *If your server supported it, it would be possible to implement a RewriteMap (http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteMap) but that would mean a program would have to be written, mod_rewrite would execute it on each page hit, and the program would return the new mapped URL to send along to the server. The program would have to look in the MODx database to find the partially matching alias. This is the same logic basically that I considered when I recommended a plugin. I’m not sure which way would be easier to program and which way would create less of a performance detriment.

              Even if you did get mod_rewrite responding to your "shortened" URLs properly, there’s the other side of the coin. When MODx generates page links, with friendly URLs turned on, it’s going to create them with the /english and /espanol directories in them. Back to a MODx plugin to parse the document for such URLs and modify them.
                Mike Schell
                Lead Developer, MODX Cloud
                Email: [email protected]
                GitHub: https://github.com/netProphET/
                Twitter: @mkschell
                • 36747
                • 138 Posts
                Thanks for the support!

                I think I will create a TV to declare the language of the pages and the use Wayfinder to filter by that TV.

                cheers
                eemi
                  patagonia, argentina