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

    Is there a preferred best way to setup 301 redirects in the htaccess file in MODX Revo?

    I've tried a traditional route but its causing the website to not work, anyone had any success? Code examples?

    Thank you

    Brett

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

      • 3749
      • 24,544 Posts
      Use a rewrite rule rather than a redirect:

      RewriteRule ^modx-snippet-parameters\.html$ /modx-snippet-properties.html? [R=301,NE,L]
      [ed. note: BobRay last edited this post 12 years ago.]
        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
        • 22969
        • 158 Posts
        Thanks BobRay,

        Where in the htaccess file do I put it, ive read it needs to go top?

        Here's one of the links (20 in total) Ive been sent to add to the htaccess - Redirect 301 /hampshire_babysitters/index.asp http://www.website.com/hampshire-childcare-services

        How does that translate using your code?

        Thanks for your help.

        Brett
        • discuss.answer
          • 3749
          • 24,544 Posts
          They usually ago just below the Rewrite Base and Options lines

          I think this would do it:

          RewriteRule hampshire_babysitters/index.asp$ http://www.website.com/hampshire-childcare-services [R=301,L]
            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
            • 22969
            • 158 Posts
            Thanks BobRay, that worked perfectly!!

            Really appreciate it.

            Brett
              • 3749
              • 24,544 Posts
              Glad to hear it. smiley
                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
                • 22969
                • 158 Posts
                Doh! Seems some are not working, im sure the format is right?

                The code is below, for example this one isnt working yet the url is correct??

                RewriteRule hampshire_babysitters/offers.asp$ http://www.freedomchildcare.com/hampshire-childcare-services [R=301,L]

                RewriteRule index.asp$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule flexinanny/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule weddingday/index.asp$ http://www.freedomchildcare.com/wedding-day-childcare [R=301,L]
                RewriteRule testimonials/index.asp$ http://www.freedomchildcare.com/references [R=301,L]
                RewriteRule hampshire_babysitters/index.asp$ http://www.freedomchildcare.com/hampshire-childcare-services [R=301,L]
                RewriteRule isle_of_wight_babysitters/index.asp$ http://www.freedomchildcare.com/isle-of-wight-childcare [R=301,L]
                RewriteRule bournemouth-babysitters/$ http://www.freedomchildcare.com/dorset-childcare-services [R=301,L]
                RewriteRule corporate/index.asp$ http://www.freedomchildcare.com/corporate-events [R=301,L]
                RewriteRule southampton_babysitters/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule chichester-babysitters/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule joinfreedom/index.asp$ http://www.freedomchildcare.com/apply-for-work [R=301,L]
                RewriteRule staff/index.asp$ http://www.freedomchildcare.com/our-staff [R=301,L]
                RewriteRule new_forest_babysitters/$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule bournemouth_mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule weddingday/iterms.htm$ http://www.freedomchildcare.com/wedding-day-childcare [R=301,L]
                RewriteRule members/index.asp$ http://www.freedomchildcare.com/wedding-day-childcare [R=301,L]
                RewriteRule mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule west_sussex_babysitters/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule recruitaupair/index.asp$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule supplycover/index.asp$ http://www.freedomchildcare.com/supply-cover [R=301,L]
                RewriteRule staff/idownloads.asp$ http://www.freedomchildcare.com/our-staff [R=301,L]
                RewriteRule prices/index.asp$ http://www.freedomchildcare.com/our-services [R=301,L]
                RewriteRule babysitting/iterms.htm$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule babysitting/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule hampshire_mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule recruitnanny/index.asp$ http://www.freedomchildcare.com/nanny-recruitment [R=301,L]
                RewriteRule portsmouth_mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule vetting/index.asp$ http://www.freedomchildcare.com/our-team [R=301,L]
                RewriteRule southampton_%20babysitters/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule creche/index.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule west_sussex_mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule ourteam/inannies.asp$ http://www.freedomchildcare.com/nanny-recruitment [R=301,L]
                RewriteRule portsmouth_babysitters/index.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule wedding_day_creche.asp$ http://www.freedomchildcare.com/wedding-day-childcare [R=301,L]
                RewriteRule isle_of_wight_mobile_creche.asp$ http://www.freedomchildcare.com/isle-of-wight-childcare [R=301,L]
                RewriteRule chichester-babysitters/$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule staff/members_index.asp$ http://www.freedomchildcare.com/our-staff [R=301,L]
                RewriteRule supplycover/iterms.htm$ http://www.freedomchildcare.com/supply-cover [R=301,L]
                RewriteRule corporate/ivetting.htm$ http://www.freedomchildcare.com/corporate-events [R=301,L]
                RewriteRule recruitaupair/imoreinfo.htm$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule recruitnanny/index.asp$ http://www.freedomchildcare.com/nanny-recruitment [R=301,L]
                RewriteRule offers.asp$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule Connections/index.asp$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule corporate/offers.asp$ http://www.freedomchildcare.com/corporate-events [R=301,L]
                RewriteRule weddingday/iabout.htm$ http://www.freedomchildcare.com/wedding-day-childcare [R=301,L]
                RewriteRule chichester_mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule babysitting/offers.asp$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule new_forest_mobile_creche.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule creche/offers.asp$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule staff/ilogin.asp$ http://www.freedomchildcare.com/staff-login [R=301,L]
                RewriteRule recruitaupair/offers.asp$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule vetting/iabout.htm$ http://www.freedomchildcare.com/quality-assurance [R=301,L]
                RewriteRule ourteam/iabout.htm$ http://www.freedomchildcare.com/our-team [R=301,L]
                RewriteRule creche/iabout.htm$ http://www.freedomchildcare.com/mobile-creche [R=301,L]
                RewriteRule recruitaupair/iterms.htm$ http://www.freedomchildcare.com [R=301,L]
                RewriteRule recruitnanny/iterms.htm$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule hampshire_babysitters/offers.asp$ http://www.freedomchildcare.com/hampshire-childcare-services [R=301,L]
                RewriteRule vetting/offers.asp$ http://www.freedomchildcare.com/training [R=301,L]
                RewriteRule bournemouth-babysitters/iabout.htm$ http://www.freedomchildcare.com/flexi-nanny-and-babysitting [R=301,L]
                RewriteRule staff/offers.asp$ http://www.freedomchildcare.com/our-staff [R=301,L]
                


                Any advice?

                Brett
                  • 3749
                  • 24,544 Posts
                  You have offers.asp$ in an earlier rule. It's matching that one first and looking no further.
                    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
                    • 22969
                    • 158 Posts
                    Quote from: BobRay at Sep 09, 2014, 04:06 AM
                    You have offers.asp$ in an earlier rule. It's matching that one first and looking no further.
                    Hi BobRay,

                    But the overall path is different? just the final part? "hampshire_babysitters/" before it?

                    So all paths are different overall.

                    Im not sure what to do?

                    Brett
                      • 3749
                      • 24,544 Posts
                      I'm talking about this one:

                      RewriteRule offers.asp$ http://www.freedomchildcare.com [R=301,L]


                      That will match any URL that ends in offers.asp, regardless of the path and send will them to the home page. Any other rewrite rules where the search string ends in offers.asp will never execute.

                      Try putting it last.

                        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