How to redirect an url in .htaccess when "redirect 301" doesnt work
-
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
-
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.
-
Sorry, I couldn't get it redirected with this, this is a really naughty url coming from an external website,
but thanks for suggestion -
Have you tried:
redirect 301 15985.jpg(.*) 15985.jpg
This should capture every string that starts with the image name.
Hope that helps.
-
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?
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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.
Related Questions
-
301 redirection help needed!
Hi all, So if we used to have a domain (let's say olddomain.com) and we had a new site created at newdomain.com how do we properly setup redirects page to page. Caveat, the urls have changed so for instance the old page oldomain.com/service is now newdomain.com/our-services on the new site. Do we need to have hosting on the old site? Do we need to setup individual 301s for each page corresponding to the new page? Just looking for the easiest way to do this CORRECTLY. Thanks, Ricky
Intermediate & Advanced SEO | | RickyShockley3 -
Relaunching website in two phases - 301 redirect approach
Hey Mozzers, Interested to know your thoughts on the following situation. I am relaunching a website with an updated URL structure in TWO phases. Phase one will be a much smaller version of the site, with 30% of the pages going live - the remaining 70% of page won't be available until Phase two. In Phase one, these 30% of pages will be 301 redirected from their like-for-like versions - old site to new site. The remaining 70%... because the like-for-like pages won't be available until Phase two, which is likely to be launched in 3 months time, should I do a temporary redirect on these pages (302) to the new homepage for the time being, until the new versions of the pages are live - and then implement the 301 from old url to new url. A bit of a messy situation, and not ideal for SEO, but my hands are tied as the organisation is pushing ahead with this phased approach. So, interested to hear your thoughts on an appropriate 301 migration plan.
Intermediate & Advanced SEO | | RWesley0 -
Is it bad I have a cluster of canonical urls that 301 re-direct?
Just went through a migration. We have a group of canonical URLs that are NOT the preferred url, but 301 re-direct to the preferred URL. Does this essentially "break even" and the incorrect canonical URL becomes obsolete? And/or would this be considered potentially bad and confusing for bots?
Intermediate & Advanced SEO | | lunavista-comm0 -
Why does old "Free" site ranks better than new "Optimized" site?
My client has a "free" site he set-up years ago - www.montclairbariatricsurgery.com (We'll call this the old site) that consistently outranks his current "optimized" (new) website - http://www.njbariatricsurgery.com/ The client doesn't want to get rid of his old site, which is now a competitor, because it ranks so much better. But he's invested so much in the new site with no results. A bit of background: We recently discovered the content on the new site was a direct copy of content on the old site. We had all copy on new site rewritten. This was back in April. The domain of the new site was changed on July 8th from www.Bariatrx.com to what you see now - www.njbariatricsurgery.com. Any insight you can provide would be greatly appreciated!!!
Intermediate & Advanced SEO | | WhatUpHud0 -
301 Redirection problems
A couple of days ago we did a restructure of our e-commerce site (wordpress + woocomerce) where some product categories needed to change names. I used Yoast SEO plugin to do 301 redirects in the .htaccess file.Today I noticed that we had two hits in the SERP on the phrase "dildos med vibrator". See the attached screenshot (first two results).One goes to http://www.oliverocheva.se/kategori/sexleksaker/dildos/dildos-med-vibrator/ which is the right URL. One goes to http://www.oliverocheva.se/kategori/sexleksaker/dildosdildos-med-vibrator-dildos-for-honom/ which is a corrupt URL that has never been in use. The old one we did a redirect from was /kategori/for-honom/dildos-for-honom/dildos-med-vibrator-dildos-for-honom/The command in the .htaccess file was: Redirect 301 /kategori/for-honom/dildos-for-honom/dildos-med-vibrator-dildos-for-honom/ http://www.oliverocheva.se/kategori/sexleksaker/dildos/dildos-med-vibratorWhat has happened here? Why does the 301 create entirely new URL:s in the SERP?Tz0TULT.png
Intermediate & Advanced SEO | | kisen0 -
Redirecting a working dynamic URI to a new static format
Hi all I am having some issues rearding url rewrites and 301 redirects with 1 and 1 hosting and am unsure of the best approach. The website is a custom made shopping cart system with categories and products. The current urls for categories are : index.php?l=product_list&c=1 The new url format required is : /banner-stands After a little bit of research I added the following into the htaccess file; Options +FollowSymlinks
Intermediate & Advanced SEO | | vividwebdesign
AddType x-mapp-php5 .php RewriteEngine On RewriteBase / RewriteRule ^banner-stands/?$ index.php?l=product_list&c=1 [R=301,NC,L] Which works but I have a few questions Question 1: Is this the best approach as there are 55 categories and 179 products to write redirects for Question 2: Or is it better to firstly add id=banner-stands into the url and then create 301 redirects to the new url and then rewrite the url. Thanks0 -
Explaining 301 redirects instead of 302
I am trying to explain in layman's terms to a client why using 302 for their redirects (which they have done themselves) is not right. There view is they do not seem to listen or believe what is being said to them and do not want to do permanent damage to the old domain so are using 302 redirects. I have explained over and over 301 is needed but I do not seem to be good at communicating this. Can someone give me a good example or description I can use to get my point across?
Intermediate & Advanced SEO | | JohnW-UK0 -
301 redirect for duplicate content
Hey, I have just started working on a site which is a video based city guide, with promotional videos for restaurants, bars, activities,etc. The first thing that I have noticed is that every video on the site has two possible urls:- http://www.domain.com/venue.php?url=rosemarino
Intermediate & Advanced SEO | | AdeLewis
http://www.domain.com/venue/rosemarino I know that I can write a .htaccess line to redirect one to the other:- redirect 301 /venue.php?url=rosemarino http://www.domain.com/venue/rosemarino but this would involve creating a .htaccess line for every video on the site and new videos that get added may get missed. Does anyone know a way of creating a rule to rewrite these urls? Any help would be most gratefully received. Thanks. Ade.0