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. Htaccess issue

    Htaccess issue

    Technical SEO Issues
    8 2 487
    • 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

      I have some urls in my site due to a rating counter. These are like:

      domain.com/?score=4&rew=25
      domain.com/?score=1&rew=28
      domain.com/?score=5&rew=95

      These are all duplicate content to my homepage and I want to 301 redirect them there. I tried so far:

      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
      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
      RedirectMatch 301 /[a-z,0-9]score[a-z,0-9] http://domain.com
      RedirectMatch 301 /[a-z,0-9,=,&]score[a-z,0-9,=,&] http://domain.com
      RedirectMatch 301 /[a-z,0-9,=&?/.]score[a-z,0-9,=&] http://domain.com

      None of them works. Anybody? Solution? Would be very much appriciated

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

        Try playing with something like this:

        Options +FollowSymLinks
        RewriteEngine on
        RewriteCond %{QUERY_STRING} ^score=[0-9]&rew=[0-9]$ 
        RewriteRule ^(.*)$ http://domain.com? [R=301,L]

        The score part of the URL are being treated as parameters.

        An alternative would be (in GWT and BWC) to tell Google/Bing to ignore the score and rew parameters

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

          Splendid 😉 You are the MAN. Thanks

          JaspalX sesertin 5 Replies Last reply Reply Quote 0
          • JaspalX
            JaspalX @sesertin last edited by

            Happy to help Zsolt, I know how frustrating it can be to get some rules working.

            Here's a great place to test regex: http://gskinner.com/RegExr/

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

              Can I ask you two more things?

              First, could you please explain the regex to me as I don't understand a few parts, so:

              RewriteCond %{QUERY_STRING} ^score=[0-9]&rew=[0-9]$
              RewriteCond this is the condition hen rewrite should take place
              % I don't know why it is necessarry just see it everywhere
              {QUERY_STRING} gets the query string
              ^ matches from beginning
              score=[0-9]* score=takes a number from 0-9 zero to more times
              &rew=[0-9]*$ again with rew=

              RewriteRule  rule fot the rewrite
              ^(.*)$ I totally don't get this one
              http://domain.com? I don't know why ? is needed
              [R=301,L] 301 redirect

              Secondly I would like to ask you for a code to remove .html endings from any urls.I think it should begin like

              RewriteCond %{QUERY_STRING} (.*).html

              But I am totally not enough for the second part. Could you please help me with this one as well?

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

                Can I suggest that you read through the docs? They're pretty good and have some nice intros:

                http://httpd.apache.org/docs/current/rewrite/

                http://httpd.apache.org/docs/current/rewrite/intro.html

                % needed since it is a variable

                ^(.*)$  is 'match the url'

                ? at the end deletes the query string that came in.

                Note, the ^(.*)$ is calculated first, then the condition.

                So the whole thing says:

                ^(.*)$   .... for any urls,

                RewriteCond.... where there is a query string with score, rel etc.http://domain.com? .... replace the whole thing with http://domain.com/

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

                  Thanks again for your help, really, much appreciated. Have a nice day.

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

                    This is the document I was searching for. I always got lost as other resources did not explain all character means but I think I will at last be able to understand this one. Thanks again

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    • Sitemap issue
                      Hutch42
                      Hutch42
                      0
                      5
                      121

                    • Crawl issues
                      Christy-Correll
                      Christy-Correll
                      0
                      3
                      105

                    • Disavow Issues
                      MarieHaynes
                      MarieHaynes
                      0
                      6
                      142

                    • WordPress Link Issue..... URL Issue.... Please Guide....!
                      evolvingSEO
                      evolvingSEO
                      0
                      3
                      234

                    • Drupal issue
                      jim_cetin
                      jim_cetin
                      0
                      4
                      533

                    • Htaccess query
                      ShaMenz
                      ShaMenz
                      0
                      6
                      469

                    • Any issues with lots of pages issuing 301 redirects?
                      RyanKent
                      RyanKent
                      0
                      2
                      600

                    • Crawl issues/ .htacess issues
                      StalkerB
                      StalkerB
                      0
                      6
                      1.1k

                    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