Skip to content
    Moz logo Menu open Menu close
    • Products
      • Moz Pro
      • Moz Pro Home
      • Moz Local
      • Moz Local Home
      • STAT
      • Mozscape API
    • Free SEO Tools
      • Competitive Research
      • Link Explorer
      • Keyword Explorer
      • Domain Analysis
      • MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO
      • SEO Learning Center
      • Moz Academy
      • SEO Q&A
      • Webinars, Whitepapers, & Guides
    • Blog
    • Why Moz
      • Agency Solutions
      • Enterprise Solutions
      • Small Business Solutions
      • Case Studies
      • The Moz Story
      • New Releases
    • Log in
    • Log out
    • Products
      • Moz Pro

        Your All-In-One Suite of SEO Tools

        The essential SEO toolset: keyword research, link building, site audits, page optimization, rank tracking, reporting, and more.

        Learn more
        Try Moz Pro free
        Illustration of Moz Pro
      • Moz Local

        Complete Local SEO Management

        Raise your local SEO visibility with easy directory distribution, review management, listing updates, and more.

        Learn more
        Check my presence
        Illustration of Moz Local
      • STAT

        Enterprise Rank Tracking

        SERP tracking and analytics for SEO experts, STAT helps you stay competitive and agile with fresh insights.

        Learn more
        Book a demo
        Illustration of STAT
      • Mozscape API

        The Power of Moz Data via API

        Power your SEO with the proven, most accurate link metrics in the industry, powered by our index of trillions of links.

        Learn more
        Get connected
        Illustration of Mozscape API
      • Compare SEO Products
    • Free SEO Tools
      • Competitive Research

        Competitive Intelligence to Fuel Your SEO Strategy

        Gain intel on your top SERP competitors, keyword gaps, and content opportunities.

        Find competitors
        Illustration of Competitive Research
      • Link Explorer

        Powerful Backlink Data for SEO

        Explore our index of over 40 trillion links to find backlinks, anchor text, Domain Authority, spam score, and more.

        Get link data
        Illustration of Link Explorer
      • Keyword Explorer

        The One Keyword Research Tool for SEO Success

        Discover the best traffic-driving keywords for your site from our index of over 500 million real keywords.

        Search keywords
        Illustration of Keyword Explorer
      • Domain Analysis

        Free Domain SEO Analysis Tool

        Get top competitive SEO metrics like Domain Authority, top pages, ranking keywords, and more.

        Analyze domain
        Illustration of Domain Analysis
      • MozBar

        Free, Instant SEO Metrics As You Surf

        Using Google Chrome, see top SEO metrics instantly for any website or search result as you browse the web.

        Try MozBar
        Illustration of MozBar
      • More Free SEO Tools
    • Learn SEO
      • Beginner's Guide to SEO

        The #1 most popular introduction to SEO, trusted by millions.

        Read the Beginner's Guide
      • How-To Guides

        Step-by-step guides to search success from the authority on SEO.

        See All SEO Guides
      • SEO Learning Center

        Broaden your knowledge with SEO resources for all skill levels.

        Visit the Learning Center
      • Moz Academy

        Upskill and get certified with on-demand courses & certifications.

        Explore the Catalog
      • On-Demand Webinars

        Learn modern SEO best practices from industry experts.

        View All Webinars
      • SEO Q&A

        Insights & discussions from an SEO community of 500,000+.

        Find SEO Answers
      The Impact of Local Business Reviews
      SEO Industry Report

      The Impact of Local Business Reviews

      Learn more
    • Blog
    • Why Moz
      • Small Business Solutions

        Uncover insights to make smarter marketing decisions in less time.

        Grow Your Business
      • The Moz Story

        Moz was the first & remains the most trusted SEO company.

        Read Our Story
      • Agency Solutions

        Earn & keep valuable clients with unparalleled data & insights.

        Drive Client Success
      • Case Studies

        Explore how Moz drives ROI with a proven track record of success.

        See What's Possible
      • Enterprise Solutions

        Gain a competitive edge in the ever-changing world of search.

        Scale Your SEO
      • New Releases

        Get the scoop on the latest and greatest from Moz.

        See What’s New
      Surface actionable competitive intel
      New Feature: Moz Pro

      Surface actionable competitive intel

      Learn More
    • Log in
      • Moz Pro
      • Moz Local
      • Moz Local Dashboard
      • Mozscape API
      • Mozscape API Dashboard
      • Moz Academy
    • Avatar
      • Moz Home
      • Notifications
      • Account & Billing
      • Manage Users
      • Community Profile
      • My Q&A
      • My Videos
      • Log Out

    The Moz Q&A Forum

    • Forum
    • Questions
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

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

    1. Home
    2. SEO Tactics
    3. Technical SEO
    4. 301 redirect

    301 redirect

    Technical SEO
    4
    27
    2345
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with question 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
      • AlanMosley
        AlanMosley @sesertin last edited by

        well done sha, i am afraid i got the wrong end of the stick, i thought he wanted to SELECT the url, not simply detect it.

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

          Glad you got it worked out 🙂

          Don't forget if you need extra help on something you can always use the Private Message system in your profile to contact people direct.

          Have a great weekend,

          Sha

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

            Yes, Sha looked at it and got a bit lost at once. I am totally new to server side codes and it needed a little modification but i got it working in the end. Thanks a lot.

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

              Hi Zsolt,

              Did you actually look at the link I gave you with the code that you needed?.

              The answer is to stop trying to use Redirectmatch and use the code I gave you in that example:

              RewriteEngine on
              
              RewriteBase /score
              
              RewriteCond %{QUERY_STRING} score=
              RewriteRule ^/*$ newlocation.html? [R=301,L]
              

              This is the simplest, cleanest, and most reliable solution to your problem.

              Sha

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

                Thanks for the help. Regretfully this is my very first time writing htaccess so lot of faults can occur. I posted another thread maybe someone knows better than I do. Thank you very much for your time.

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

                  Well that will select your url, but what are you trying to do with it.

                  i have it working on IIS server using that regex, but i cant tell you how to use it in htaccess, as i dont use it

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

                    nothing works. maybe I'll try posting another thread.

                    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
                      • 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

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

                          1 Reply Last reply Reply Quote 1
                          • 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
                            • 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

                                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.

                                  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

                                    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 @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
                                      • sesertin
                                        sesertin @ShaMenz last edited by

                                        Thank  you a lot for your help, very much appriciated

                                        1 Reply Last reply Reply Quote 0
                                        • 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
                                          • 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
                                            • 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
                                              • sesertin
                                                sesertin @ShaMenz last edited by

                                                You got it right

                                                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
                                                  • 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
                                                    • 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
                                                      • 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 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
                                                          • 1 / 1
                                                          • First post
                                                            Last post

                                                          Got a burning SEO question?

                                                          Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.


                                                          Start my free trial


                                                          Browse Questions

                                                          Explore more categories

                                                          • Moz Tools

                                                            Chat with the community about the Moz tools.

                                                          • SEO Tactics

                                                            Discuss the SEO process with fellow marketers

                                                          • Community

                                                            Discuss industry events, jobs, and news!

                                                          • Digital Marketing

                                                            Chat about tactics outside of SEO

                                                          • Research & Trends

                                                            Dive into research and trends in the search industry.

                                                          • Support

                                                            Connect on product support and feature requests.

                                                          • See all categories

                                                          Related Questions

                                                          • matthewparkman

                                                            Old Content after 301 Redirect Success

                                                            Hi, I want to ask what need I do to the old content after my 301 redirect to the new domain with the same content success? Do I need to remove that old content? Nothing bad happen right? Thanks

                                                            Technical SEO | | matthewparkman
                                                            0
                                                          • Kapottefietsband

                                                            301 redirects don't work properly

                                                            Hello all, I've been working on 301 redirects for a bit and normally it's no problem but some seem to be going wrong. Redirect 301 /3-zits.html http://www.bankstellenshop.com/banken/3-zits.html This one works properly but the following one gives a very strange result as it goes to http://www.bankstellenshop.com/bankstellen.html/u (no idea where the .html comes from) Redirect 301 /bankstellen/u http://www.bankstellenshop.com/bankstellen/u.html Any idea what I'm doing wrong or what should change? Thanks in advance!

                                                            Technical SEO | | Kapottefietsband
                                                            0
                                                          • madegood

                                                            301 redirect chains

                                                            Hi everyone, I've had my site for a while now and have changed the structure a number of times. I'm confident my 301's work well and am not concerned about dead ends on my site. My question is, is there a way to find 301 redirect chains? i.e. can I export my link data from webmaster tools and run it through some software that tells me how many steps my 301's are taking to get to the final page? I don't know for sure that there are long 301 chains in my link structure, but I have a suspicion and it's very hard to check by going through them manually. Thanks in advance Will

                                                            Technical SEO | | madegood
                                                            0
                                                          • gaytravel

                                                            What is the difference between 301 redirect to 404 vs just 404.

                                                            A bunch of pages on my site are set to 301 redirect to our 404 page. Intuitively, I feel like they should all just 404 from the page's url and not redirect to the 404 page. How do I explain to my developer that they should not redirects but should just 404? Is there much of a difference between the redirect first vs 404 first? Thanks!

                                                            Technical SEO | | gaytravel
                                                            0
                                                          • TSpike1

                                                            Is Buying Domains Good For SEO? Can I 301 redirect domains to an Original website?

                                                            I have a friend that purchased multiple domains related to their website. Each of these domains have the back ground of the original website and irrelevant content on them. Is is possible to redirect the various domains to certain pages on the original website. For example if the website is www.shoes.com and they purchased domains such as www.leathermensshoes.com and a few others related to the website. Is it SEO friendly to link the domains purchased to the original website?

                                                            Technical SEO | | TSpike1
                                                            0
                                                          • Room214

                                                            301 Redirect Domain or 301 Redirect Domain + Interior Pages

                                                            Hello - My company acquired another company in our industry and our IT team immediately set up the acquired companies domain name as a an alias to our site. This created a duplicate version of our website under another domain name and Google started ranking interior pages from the aliased acquired site for several top keywords that were previously held by our real site. Should we 301 redirect just the top level domain name of the acquired site to the real site or 301 redirect the top level domain name and the interior pages on the acquired site to help ensure that our real domain will take back the rankings it once had? Thanks!

                                                            Technical SEO | | Room214
                                                            0
                                                          • EvergladesDirect

                                                            200 Redirects for SEO instead of 301

                                                            We are working with a company on re-platforming our website.  On a call yesterday they outlined a strategy to use 200 redirects for our top keywords instead of 301s.  I am not familiar with this type of redirect and was wondering if anyone could provide some more insight.

                                                            Technical SEO | | EvergladesDirect
                                                            0
                                                          • Yozzer

                                                            301 redirect

                                                            We have just had an outside SEO agency report on our site: One of things brought up were arounf broken links, and how they class them as broken links. Could any body tell me whether this statement holds true please, as I am not aware of this "Our latest intelligence shows that google are downgrading ranking from sites that feature 301 redirects within the internal link structure". Any help would be greatly appreciated Regards

                                                            Technical SEO | | Yozzer
                                                            0
                                                          Moz logo
                                                          • Contact
                                                          • Community
                                                          • Free Trial
                                                          • Terms & Privacy
                                                          • Jobs
                                                          • Help
                                                          • News & Press
                                                          • Mozcon
                                                          © 2021 - 2023 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.

                                                          Looks like your connection to Moz was lost, please wait while we try to reconnect.