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 non existant pages

    301 Redirect non existant pages

    Technical SEO Issues
    6 3 174
    • 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.
    • Cocoonfxmedia
      Cocoonfxmedia last edited by

      Hi

      I have 100's of URL's appearing in Search Console for example:

      ?p=1_1

      These go to on to 5_200 etc..

      I have tried to do htaccess and the mod rewrite is on as I can redirect directories to the root i.e

      RewriteRule ^web_example(.*)$ /$1 [R=301,N,L]

      However I have tried all kinds of variations to redirect ?p= and either it doesn't work at all or it crashes the website. Can anyone point me in the right direction to fix this.

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

        Hi,

        Something is generating those links, and that is what I would want to fix. It sounds like a module or add-on is incorrectly coded, or installed improperly. As p=1_1 is usually a form of pagination and / or sort order.

        You could of course easily fix it by putting a canonical tag on the root page to itself or work out a mod rewrite rule, but that isn't actually fixing the problem. As soon as you add another category you may have to revisit the fix again.

        Here is an example of using mod re-write on Stack Overflow: http://stackoverflow.com/questions/14666140/htaccess-rewriting-php-pagination

        I hope that helps,

        Don

        Cocoonfxmedia 1 Reply Last reply Reply Quote 1
        • Cocoonfxmedia
          Cocoonfxmedia @donford last edited by

          It's from an old website so the pages no longer exist. I will have a look at the link you sent over thank you.

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

            Hi James,

            Assuming you want to keep the existing setup but set up friendlier URLs (example, redirect ?p=1_14 to /p/1_14), you could do something like this:

            RewriteCond %{REQUEST_URI} ^p=([^&]+) [NC,OR]
            RewriteCond %{REQUEST_URI} &p=([^&]+) [NC]
            RewriteRule .* /p/%1? [R=301,L,NE]

            Then you'd want something to handle those new URL requests with something like this:

            RewriteRule "^p/(.*)$" "/index.php?p=$1" [L,NE]

            Hope this helps!

            Cocoonfxmedia 1 Reply Last reply Reply Quote 1
            • Cocoonfxmedia
              Cocoonfxmedia @chrissmithps last edited by

              Thanks Chris

              Seems there is an issue with the web host.

              1 Reply Last reply Reply Quote 1
              • Cocoonfxmedia
                Cocoonfxmedia last edited by

                RewriteCond %{QUERY_STRING} ^p=([0-9_])$
                RewriteRule ^(.
                )$ /p/%1? [R=301,L]

                the above works on our test area but not on clients so it hosting issue

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • Page for page 301 redirects from old server to new server
                  cindyt-17038
                  cindyt-17038
                  0
                  5
                  398

                • Advice on whether we 301 redirect a page or update existing page?
                  tomwhite
                  tomwhite
                  0
                  2
                  83

                • 301 redirect all 404 pages
                  alsvik
                  alsvik
                  0
                  8
                  3.6k

                • How does this rank? - a page that is 301 redirected
                  Morris77
                  Morris77
                  0
                  5
                  279

                • How to verify a page-by-page level 301 redirect was done correctly?
                  EvolveCreative
                  EvolveCreative
                  0
                  5
                  269

                • Is it better to delete web pages that I don't want anymore or should I 301 redirect all of the pages I delete to the homepage or another live page?
                  EGOL
                  EGOL
                  0
                  2
                  417

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

                • On Page 301 redirect for html pages
                  randfish
                  randfish
                  0
                  7
                  1.6k

                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