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. Intermediate & Advanced SEO
    4. 301 redirect with /? in URL

    301 redirect with /? in URL

    Intermediate & Advanced SEO
    5 4 736
    • 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.
    • COEDMediaGroup
      COEDMediaGroup last edited by

      For a Wordpress site that has the ending / in the URL with a ? after it... how can you do a 301 redirect to strip off anything after the /

      For example how to take this URL

      domain.com/article-name/?utm_source=feedburner

      and 301 to this URL

      domain.com/article-name/

      Thank you for the help

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

        Do you want to capture the parameter value or do you want to just remove it immediately? If you want to remove it without worrying about capturing the value in Google Analytics, then this code may work -

        RewriteEngine On
        RewriteCond %{QUERY_STRING} !="" #if there is a query string
        RewriteCond %{QUERY_STRING} !^p=.* #wordpress users: allow post tempalinks
        RewriteCond %{REQUEST_URI} !^/wp-admin.* #wordpress users: don't break admin
        RewriteRule ^(.*)$ /$1? [R=301,L] #remove query string

        I got this code from http://briancray.com/posts/htaccess-hack-remove-url-query-strings/

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

          Just looking to remove it. Thanks for the info, will see if this works.

          Aleyda 1 Reply Last reply Reply Quote 0
          • AmberRobinson
            AmberRobinson last edited by

            Have you tried the Redirection tool when you login to the back-end of the site?

            1 Reply Last reply Reply Quote 0
            • Aleyda
              Aleyda @COEDMediaGroup last edited by

              Hi Robert,

              The rewrite rules shared by Patrick should work well for that although you could also use Yoast's Wordpress SEO plugin that features options to do that through the control panel.

              Nonetheless, in general what can be better in performance and also for tracking purposes with your site URL, leaving tracking parameters while avoiding content duplication content is to use canonical tags. You can also set them easily for Wordpress with Yoast's plugin.

              I hope this helps!

              Aleyda

              1 Reply Last reply Reply Quote 2
              • 1 / 1
              • First post
                Last post
              • Redirect wordpress from /%post_id%/%postname%/ to /blog/%postname%/
                Taiger
                Taiger
                0
                3
                446

              • URL Redirect: http://www.example.net/ vs. http://www.example.net
                dotfly
                dotfly
                0
                2
                705

              • How to use a 301 Redirect when the first 301 Redirect is not the same as what's indexed?
                PatriotOutfitters81
                PatriotOutfitters81
                0
                3
                66

              • 301 Redirect To Another 301 Redirect
                cbielich
                cbielich
                0
                5
                247

              • How to 301 redirect all URLs with /? in?
                JohnPeters
                JohnPeters
                0
                9
                331

              • Help with setting up 301 redirects from /default.aspx to the "/" in ASP.NET using MasterPages?
                BrianCrouch
                BrianCrouch
                0
                2
                595

              • Can some brilliant mozzer out there teach a moron/newbie like me how to 301 redirect several URL's I have?
                AlanMosley
                AlanMosley
                0
                7
                487

              • Question about 301 redirect for trailing / ?
                YannickVeys
                YannickVeys
                0
                4
                524

              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