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

    Bit of a large topic I know but can someone please run through the procedure for creating the ultimate pretty url in Modx please?
    I have tried using this guide: http://rtfm.modx.com/revolution/2.x/administering-your-site/using-friendly-urls but it creates a lot of problems. Some pages create urls which when you click to visit another page, seem to take the previous url as the base. (For example, must pages create urls such as www.mysite.com/page-name.html but some of them create urls like this: www.mysite.com/page-name and when I click to visit the another page it goes to www.mysite.com/page-name/next-page.html instead of www.mysite.com/next-page.html).

    Also it puts .html at the end of the url chich I don't want. Pagination with GetPage doesn't work either. If someone could explain the correct way to do it that would be great.

    For arguments sake we'll define the 'ultimate' pretty url as: www.domain.com/section/subsection/page-name

    Questions I would like to answer are:

    Do I need to define a canonical link in the header? If so how do I go about it?
    When my site is being crawled, will the search engine index the old style link or the pretty url? If it's the old style link, how can I get it to index the pretty url?
    If the page is not part of a section (i.e. www.domain.com/page-name) is there a way of creating a custom path (i.e. www.domain.com/my/custom/path/page-name)?
    Do I need to create 301 redirects pointing the old style urls to the new ones?

    Also as a separate question, what is the reason that Modx doesn't do this out of the box? Are there any plans to have pretty urls as standard?

    Thanks for your time. [ed. note: Wilbo last edited this post 9 years, 1 month ago.]
    • MODX Doesn't use FURLs by default because they will not work properly unless, a) the .htaccess file is in place, b) your template properly includes the base element which MODX FURLs depend on to work properly (See step 3 in the tutorial you linked to). MODX will work using query strings and id's without the .htaccess at web root and will, therefore, work properly on initial install. One further point, MODX works on a variety of servers including the now very popular nginx which requires it's on nginx conf file to handle rewrites.

      There are reasons you may not want MODX to automatically install the .htaccess, not the least of which is overwriting an existing .htaccess in the same directory. That said, these are factors that could be handled as a step in the installer but at this time it is not.

      You can use a custom path to any resource by using Freeze URI on the Resource Properties. You can include paths, whether they exist or not. You might want to add 301s if you are changing the URI and there was a previously indexed URI.

      There is also an extra called Redirector that you can use to set up redirects inside MODX, though it may be more efficient to do a small number of redirects in your .htaccess (assuming you're using Apache).

        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
        • 5160
        • 118 Posts
        Some pages create urls which when you click to visit another page, seem to take the previous url as the base
        Have you set an appropriate base tag in your Template:

        <base href="[[++site_url]]" />


        Also it puts .html at the end of the url chich I don't want.
        So take the .html extension off the HTML Content Type: Content > Content Types in the Manager (2.3)
        http://rtfm.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources/content-types

        Pagination with GetPage doesn't work either. If someone could explain the correct way to do it that would be great.
        That's not a lot to go on. Perhaps this is related to your base tag issue? Does Pagination still fail if you disable Friendly URLs to test?
        • Asking about getPage here isn't a good fit as it's not at all related to your issue with the FURLs. I think you should be able to make them work now.

          I'd recommend posting a new thread on getPage with more detailed explanation of what you've implemented and what is not working.

          Cheers,

          Jay
            Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. BlogTwitterLinkedInGitHub
            • 32391
            • 37 Posts
            Thanks guys, I was able to get it working correctly with your advice.
            Could you give me any hints for best practices regarding search engines? Canonical link setup etc.