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
-
Htaccess or url rewrite module for Magento 301 redirects?
I need to do about 6000 redirects for a Magento site. The pages no longer exist. I have tried the URL rewrite module but it isn't working for me and I don't want to do 6000 redirects in the htaccess files. Any suggestions?
Intermediate & Advanced SEO | | Tylerj0 -
Hundreds of 301 Redirects. Remove Pages or Not?
Hi Mozers, I have a website that has literally got hundreds of 301 redirects. I had a close look at these URLs and only some of them have backlinks to it and remaining all of them are not indexing in Google and has got not backlinks at all. Based on what I have noticed experts mentioning, loads of 301 redirects can potentially slow down the site speed. In a case like the website I have, should I completely take off the pages from website to reduce the number of 301 redirects or should I leave 301 redirects? There is no traffic or backlinks coming from these URLs. Malika
Intermediate & Advanced SEO | | Malika10 -
301 redirecting staff Domain to Company Domain
My colleague owns a domain (A) for about 10 years that he does not use. The domain's content is the same as my company's website (B) content.
Intermediate & Advanced SEO | | khi5
Question: Can I 301 redirect domain A to domain B's homepage or is it better he just closes down his website since this would not be SEO best practices? thank you0 -
Handling 301 Redirects when Moving from IIS to Apache Linux
I am moving a blog from domain A on IIS to domain B on Linux. Same posts and pages - different domain. I'm looking for a guide, article or steps on what needs to be done on the IIS side to make sure we do this correctly. Thanks !
Intermediate & Advanced SEO | | GlennFerrell0 -
How should we 301 redirecting ecommerce microsite to our larger ecommmerce site? Should we?
We have several microsites (by microsite I mean sites that are basically top-level departments of our main ecommerce site. We continue to run these, without much support, and they do generate a few sales but we simply don't have the resources to grow them or manage them effectively. We have "kicked around" the idea of 301 redirecting them to our main ecommerce site with the idea that any additional SEO value would be greater than the few sales they currently generate. All products that are on our microsites can be found on our main ecommerce site, thus we can redirect products on our microsites to the exact product on our main site. How would you treat these sites? Would you 301 redirect them? If so, how would you do it? What would be some considerations if we decide to 301 redirect? Microsite example: http://www.drinkingstuff.com/ Main site: http://www.prankplace.com/ I would greatly appreciate any tidbits the community could provide us on this. Thanks!
Intermediate & Advanced SEO | | Istoresinc0 -
New to SEO. How do I set up a 301 Redirect? What Else should I do?
Hello, I am new to web design. I designed my own site using dreamweaver and did all my seo on my own, I read a few books. Long story short I rank on the bottom of page 1 just after 3 months and the keywords are highly competitive. Now, I am up against some heavy hitters from national brands versus my local real estate site. I don't have a 301 redirect, and am not sure what else I should be doing to get my site ranked higher. I have back links from various sites, ( non-paid ) so it's what others call white hat. When I grade my site on website grader I get a great score versus the sites that are higher than me. I'm guessing my sites age is an issue. I guess I'm looking for some guidance. Thank you all, Here is my site to view. http://www.bronxpad.com
Intermediate & Advanced SEO | | bronxpad0 -
Choose of destination for a 301 redirection
Hi, I had a website paris-football.com which ranked quite well on specific request as 'paris football" and "paris foot". I decided 2 months ago to stop this website as I had no time to update it and it was quite rubish in terms of content and make a redirection to a better quality website. I decided to redirect to the deep url http://www.sportytrader.com/paris-foot.php . The destination Url has not beneft from the redirection and has even seen its rankings drop since the redirection. do you think that it would have been better to redirect to the Home Page http://www.sportytrader.com ? Do you think that I can still change the destination url ? Thanks a lot for your help,
Intermediate & Advanced SEO | | jarnac0 -
301 Redirect using rewrite rule in .htaccess
Hi guys, I have these types of URLs with the format below that are seen as duplicate contents http://www.mysite.com/index.php?a=11&b=15&d=3&c=1 I wanted to permanently redirect them to my homepage. I am thinking if this is possible in .htaccess using rewrite conditions? Thanks in advance...
Intermediate & Advanced SEO | | Trigun0