The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. 301 redirect

    301 redirect

    Technical SEO Issues
    27 4 1.9k
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sesertin
      sesertin last edited by

      What is a proper way to redirect any url containing a give word (anywhere in the url) to another sepcified url? Is it like this?

      RedirectMatch 301 ^thisword$ http://domain.com/newlocation
      
      1 Reply Last reply Reply Quote 1
      • SimonCullum
        SimonCullum last edited by

        Hi Zsolt

        You'll find a blog post here on SEOmoz really useful, entitled "URL Rewrites and 301 Redirects - How Does It All Work" by Jennifer Sable Lopez (SEOmoz Staff).

        There is a section on the '301 Redirect process', you may also find the first section 'URL Rewrites' helpful.

        There are some useful links within, depending on whether you're using Apache or IIS.  The reason for the redirect and your technical environment will determine the most appropriate way.

        RedirectMatch 301 /folder/filename.php http://www.domain.com/newlocation

        is probably what you're after anyway going by your example in your question.

        Also some really helpful information at http://www.seomoz.org/learn-seo/redirection

        Hope that helps,

        Regards

        Simon

        sesertin 1 Reply Last reply Reply Quote 1
        • sesertin
          sesertin @SimonCullum last edited by

          Not exactly what I was looking for but thanks for the feedback anywy

          SimonCullum sesertin 2 Replies Last reply Reply Quote 0
          • SimonCullum
            SimonCullum @sesertin last edited by

            Ok, as I'd like to help, just looking at your exact question then:

            Is it like this?

            RedirectMatch 301 ^thisword$ http://domain.com/newlocation
            

            My answer was:

            
            **RedirectMatch 301 /folder/filename.php http://www.domain.com/newlocation** 
            
            is probably what you're after anyway going by your example in your question.
            
            which seems to answer the question asked, just provided a lot more information to help further.
            
            If that's not what you're after, could you rephrase the question so that you can get the help you are after?
            
            Regards
            
            Simon
            
            ```
            1 Reply Last reply Reply Quote 0
            • ShaMenz
              ShaMenz last edited by

              Hi Zsolt,

              Just so we understand exactly what you are asking here ...

              What you are wanting to do is permanently redirect any and all URLs containing "thisword" to a single URL on the same domain? Is that accurate?

              Sha

              sesertin 1 Reply Last reply Reply Quote 0
              • sesertin
                sesertin @sesertin last edited by

                I'm looking for a method to redirect any urls containing a certain variable. I have  a scorable element on my site and each time a new score is added a new url is generated like domain.com/xyz?score=5 or domain.com/score=4&rew=22. These are all alternates of my main page abd I would like to redirect them there. In the end found something when clicking through from Jennifer's post but I'm still not quite sure.

                1 Reply Last reply Reply Quote 0
                • sesertin
                  sesertin @ShaMenz last edited by

                  You got it right

                  1 Reply Last reply Reply Quote 0
                  • sesertin
                    sesertin last edited by

                    I think it should be something like

                    Redirectmatch 301 /.*thisword.``* http://domain.com

                    Maybe but I am not sure, would be grateful for feedback

                    ShaMenz 1 Reply Last reply Reply Quote 0
                    • ShaMenz
                      ShaMenz @sesertin last edited by

                      Hi again,

                      We set up an example page for you with working tests and links to example code and zipped version.

                      Hope that is what you need,

                      Sha

                      sesertin 1 Reply Last reply Reply Quote 1
                      • AlanMosley
                        AlanMosley last edited by

                        the ^ symbol means the begins with, the $ means ends with

                        so ^thisword$ means the URL must be a exact match "thisword"

                        try simply thisword

                        sesertin 1 Reply Last reply Reply Quote 0
                        • sesertin
                          sesertin @ShaMenz last edited by

                          Thank  you a lot for your help, very much appriciated

                          1 Reply Last reply Reply Quote 0
                          • sesertin
                            sesertin @AlanMosley last edited by

                            Thanks, Alan. Not really like that, as my url contains additional characters both in the front and at the end of the word. By the way the links you sent me on the topic were great I am just having some hard time to understand them, they are a bit chinese to me, as I have no basics at all writing htaccess.

                            AlanMosley sesertin ShaMenz 15 Replies Last reply Reply Quote 0
                            • AlanMosley
                              AlanMosley @sesertin last edited by

                              Did you try it, it works for me.

                              Just try simply thisword

                              it should match aaaathiswordaaaaa

                              this will work,

                              [a-z]thisword [a-z]

                              but so will

                              thisword

                              1 Reply Last reply Reply Quote 0
                              • sesertin
                                sesertin @sesertin last edited by

                                still not working for me.

                                The exact url is domain.com/?score=4&rew=25   (there are some more versions of course with different counters)

                                I want to redirect all urls like this to domain.com

                                tried:

                                RedirectMatch 301 /[a-z]score[a-z] http://domain.com
                                RedirectMatch 301 /.score. http://domain.com
                                RedirectMatch 301 /^score$.* http://domain.com
                                RedirectMatch 301 /.^score$.* http://domain.com

                                none of them woks

                                1 Reply Last reply Reply Quote 0
                                • AlanMosley
                                  AlanMosley @sesertin last edited by

                                  i work on microsoft servers, so i am not sure about the sytax of htaccess.

                                  but the regex is the same.

                                  please try these.

                                  RedirectMatch 301 [a-z]score[a-z] http://domain.com
                                  RedirectMatch 301 score http://domain.com

                                  you missed the *

                                  1 Reply Last reply Reply Quote 0
                                  • sesertin
                                    sesertin @sesertin last edited by

                                    Still not working for me. I tried further with:

                                    RedirectMatch 301 [.]score[.] http://domain.com  (I thought a-z stands just for letter and urls contain number and marks)
                                    RedirectMatch 301 [.]score[.] http://domain.com

                                    neither works

                                    1 Reply Last reply Reply Quote 0
                                    • AlanMosley
                                      AlanMosley @sesertin last edited by

                                      You are correct, give me a munite and ill get back to you

                                      1 Reply Last reply Reply Quote 0
                                      • AlanMosley
                                        AlanMosley @sesertin last edited by

                                        try [a-z,0-9]score[a-z,0-9]

                                        1 Reply Last reply Reply Quote 1
                                        • AlanMosley
                                          AlanMosley @sesertin last edited by

                                          [a-z,0-9,=,&]alan[a-z,0-9,=,&]

                                          get the idea

                                          1 Reply Last reply Reply Quote 1
                                          • AlanMosley
                                            AlanMosley @sesertin last edited by

                                            Here this will select your whole url

                                            [a-z,0-9,=&?/.]score[a-z,0-9,=&]

                                            1 Reply Last reply Reply Quote 1
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            • 301 Redirects
                                              TheeDigital
                                              TheeDigital
                                              0
                                              3
                                              258

                                            • 301 Redirect
                                              WyzeOwl
                                              WyzeOwl
                                              0
                                              5
                                              89

                                            • Redirect a 301 Redirect
                                              RedCaffeine
                                              RedCaffeine
                                              0
                                              5
                                              98

                                            • 301 Redirect
                                              KaneJamison
                                              KaneJamison
                                              0
                                              8
                                              408

                                            • Redirects 301
                                              PedroM
                                              PedroM
                                              0
                                              5
                                              639

                                            • 301 Redirect Domain or 301 Redirect Domain + Interior Pages
                                              Room214
                                              Room214
                                              0
                                              7
                                              1.1k

                                            • 301 Redirects
                                              rickdronkers
                                              rickdronkers
                                              0
                                              2
                                              937

                                            • 301 redirect
                                              Jeepster
                                              Jeepster
                                              0
                                              18
                                              2.7k

                                            Get started with Moz Pro!

                                            Unlock the power of advanced SEO tools and data-driven insights.

                                            Start my free trial
                                            Products
                                            • Moz Pro
                                            • Moz Local
                                            • Moz API
                                            • Moz Data
                                            • STAT
                                            • Product Updates
                                            Moz Solutions
                                            • SMB Solutions
                                            • Agency Solutions
                                            • Enterprise Solutions
                                            • Digital Marketers
                                            Free SEO Tools
                                            • Domain Authority Checker
                                            • Link Explorer
                                            • Keyword Explorer
                                            • Competitive Research
                                            • Brand Authority Checker
                                            • Local Citation Checker
                                            • MozBar Extension
                                            • MozCast
                                            Resources
                                            • Blog
                                            • SEO Learning Center
                                            • Help Hub
                                            • Beginner's Guide to SEO
                                            • How-to Guides
                                            • Moz Academy
                                            • API Docs
                                            About Moz
                                            • About
                                            • Team
                                            • Careers
                                            • Contact
                                            Why Moz
                                            • Case Studies
                                            • Testimonials
                                            Get Involved
                                            • Become an Affiliate
                                            • MozCon
                                            • Webinars
                                            • Practical Marketer Series
                                            • MozPod
                                            Connect with us

                                            Contact the Help team

                                            Join our newsletter
                                            Moz logo
                                            © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                                            • Accessibility
                                            • Terms of Use
                                            • Privacy