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. How to redirect an url in .htaccess when "redirect 301" doesnt work

    How to redirect an url in .htaccess when "redirect 301" doesnt work

    Intermediate & Advanced SEO
    5 3 173
    • 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.
    • Status
      Status last edited by

      I have an odd page url, generated by a link from an external website, it has:

      %5Cu0026size=27.4KB%5Cu0026p=dell%20printers%20uk%5Cu0026oid=333302b6be58eaa914fbc7de45b23926%5Cu0026ni=21%5Cu0026no=24%5Cu0026tab=organic%5Cu0026sigi=11p3eqh65%5Cu0026tt=Dell%205210n%20A4%20Mono%20Laser%20Printer%20from%20Printer%20Experts%5Cu0026u=fb

      ,after a .jpg image url, and I can't get it redirect using the redirect 301 in .htaccess to the properly image url as I use to do with the rest of not found urls

      eg: /15985.jpg%5Cu0026size=27.4KB%5Cu0026p=dell%20printers%20uk%5Cu0026oid=333302b6be58eaa914fbc7de45b23926%5Cu0026ni=21%5Cu0026no=24%5Cu0026tab=organic%5Cu0026sigi=11p3eqh65%5Cu0026tt=Dell%205210n%20A4%20Mono%20Laser%20Printer%20from%20Printer%20Experts%5Cu0026u=fb

      to just: /15985.jpg

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

        There's a few different methods of doing a redirect or a rewrite which might work. What code are you trying to use for the 301?

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

          Have you tried:

          redirect 301 15985.jpg(.*) 15985.jpg

          This should capture every string that starts with the image name.

          Hope that helps.

          Status 1 Reply Last reply Reply Quote 0
          • Status
            Status @WilliamKammer last edited by

            Sorry, I couldn't get it redirected with this, this is a really naughty url coming from an external website,
            but thanks for suggestion

            WilliamKammer 1 Reply Last reply Reply Quote 0
            • WilliamKammer
              WilliamKammer @Status last edited by

              Sorry, I should have clarified. The redirect needs the full path of the image. The actual redirect would be something Ike:

              Redirect 301 /images/15985.jpg(.*)   /images/15985.jog

              depending on where the image actually lives.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • Mass 301 redirect in htaccess
                moon-boots
                moon-boots
                0
                4
                100

              • Redirect old "not found" url (at http) to new corresponding page (now at https)
                KingRosales
                KingRosales
                0
                4
                312

              • How do you 301 redirect URLs with a hashbang (#!) format? We just lost a ton of pagerank because we thought javascript redirect was the only way! But other sites have been able to do this – examples and details inside
                JamesTDG
                JamesTDG
                0
                9
                7.9k

              • Should /node/ URLs be 301 redirect to Clean URLs
                MargaritaS
                MargaritaS
                0
                3
                172

              • .htaccess 301 Redirect Help! Specific Redirects and Blanket Rule
                LynnPatchett
                LynnPatchett
                0
                3
                3.1k

              • 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

              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