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

Answered 301 Redirects

    • 36582
    • 463 Posts
    I'm redeveloping a site (in Modx naturally!).

    The old site has URLs in the following format...

    http://www.mywebsite.com/my-page/4532525756
    http://www.mywebsite.com/my-next-page/4573088865
    http://www.mywebsite.com/my-other-page/4532523340

    Even the home page has a second life as...

    http://www.mywebsite.com/welcome/4585207669

    Anyone know of a redirect that will either 'lose' the ten digits on the end of every page or everything after the last '/' ? So I end up with...

    http://www.mywebsite.com/my-page/
    http://www.mywebsite.com/my-next-page/
    http://www.mywebsite.com/my-other-page/

    I do also need to set up some specific redirects for certain pages.

    Any help, much appreciated.

    This question has been answered by chrisandy. See the first response.

      Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
      • 38850
      • 110 Posts
      I assume the numbers must mean something. Are they IDs or connected to values in a database or 3rd party integrations?
      I mean, if you drop them, does something break?

      Assuming nothing breaks, how many pages are we talking here? Does every single page follow the exact format where there is just a number on the end? And your NEW pages are exactly the same sans the number?

      Obviously this kind of rewrite would be done in htaccess unless you had some reason to want another method. MODX can be used with a special plugin to act as a catch-all where you can write your own code to check URLs before sending people to a 404. That method is probably slower than htaccess.

      htaccess can do the general rewrites as well as the specific ones.

      I'm just wondering first if you have htaccess or if you're on nginx or something else. And how many pages you're talking about. And whether all pages are in the exact same format.

      With that info we can start to construct the htaccess rewrites.
      • discuss.answer
        • 36582
        • 463 Posts
        Firstly - apologies Vigilante and thank you for your interest in this. Unfortunately I had to take some time off as my Mother became very ill after a fall.

        I believe the numbers were just a way of making unique URLs - I couldn't find any other reason for them being there.

        We were talking about 300 pages but I worked out which were the priority pages and was able to get this down to about 60 - the rest really weren't 'worth' anything. With this in mind I was able to manually redirect in .htaccess. I used a custom 404 page to capture the rest.

        With the new structure in place the site is behaving very well.


          Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk