1

I have been checking webmaster tools and found that Google has picked up some soft 404s.

The weird thing is there are no such pages on my site and I dont know how Google has come up with these URLs.

There are over a dozen in total and here is a few examples:

www.mywebsite.com/products/manufacturers.php?&l=a
www.mywebsite.com/products/manufacturers.php?&l=b
www.mywebsite.com/products/manufacturers.php?&l=c

They basically just have a different variable at the end.

So I have tried doing a 301 redirect to our home page like so:

RedirectMatch 301 ^/products/manufacturers.php?&l=(.*)$ /

But it doesn't work it just send me to the custom error page because obviously the page its looking for doesn't exist.

I also tried a rewriteRule instead of a 301 redirect but that didn't work either.

Does anybody have any idea how I can make the redirect work so I can remove these from webmaster tools?

  • 1
    You could be getting a "soft 404" if your "custom error page" is not returning a 404 HTTP status code. If a page doesn't exist on your site then the correct response is a 404 - you should not be trying to redirect this to your home page! – MrWhite Mar 17 '15 at 10:49
0

It seems that there is some mistakes in your regex. Have you tried like bellow :

RedirectMatch 301 ^products/manufacturers\.php?&l=(.*)$ /

EDIT: Is products/manufacturers\.php a real page of your site ? Otherwise you could use

RewriteEngine on
RewriteRule ^products/manufacturers\.php(.*)$ / [L,R=301]

Tell me if it works

  • I'm not an expert on Regex but I tried your answer and had no luck. The result is the same. I thought the only regex in my original redirect line was (.*). It really is very strange because I see nothing wrong with my redirect and I'm lost as to how Google has these URLs in the first place – Kevlar Mar 17 '15 at 10:06
  • I think the query string in your regex is the problem but i'm not sure. I've edit my answer above, take a look and keep me posted. – ben Mar 17 '15 at 10:16
  • No these were not real pages. I had a products.php page and a manufacturers.php page but not products/manufacturers.php. Anyway I have tried that rewriteRule under your edit and it works. Thank you for that I have been stuck on this for hours. :) – Kevlar Mar 17 '15 at 10:29
  • A bit of an aside, but... you can't match the query string in the URL using mod_alias RedirectMatch or mod_rewrite RewriteRule alone (which is why the redirect was initially failing). You need to use RewriteCond. (Although it seems you don't need to match the query string anyway, just the path part of the URL is sufficient.) Incidentally, ^products/manufacturers\.php(.*)$ would be the same as ^products/manufacturers\.php (the (.*)$ at the end is unnecessary). However, it is a bad idea to redirect a URL that should be returning a 404 - the URL has never actually existed. – MrWhite Mar 17 '15 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.