3

I am getting 404 errors in Google Search Console for URLs like the following:

http://www.example.com/newsite12121212121212/eg/st_tour/perma/
http://www.example.com/newsite12121212121212/eg/st_activity/extreme-biking/
http://www.example.com/newsite12121212121212/eg/st_activity/extreme-biking/?currency=EUR
http://www.example.com/newsite12121212121212/eg/st_rental/new/?currency=EUR
http://www.example.com/eg-login/?location_id=1680&s=France&currency=ALL&orderby=price_desc

I want to redirect all of these to the home page of my site as the pages do not exist.

Problem # 1: I want to redirect any page that is under /newsite12121212121212/ (including any subdirectory) to the home page.

Problem # 2: ?currency= some thing, take it back to home page. I tried

RewriteEngine On
RewriteCond %{QUERY_STRING} ^currency=$
RewriteRule ^$ https://www.example.com/? [R=301,L]

It's working for the http://www.example.com?currency=EUR URL but fails on http://www.example.com/eg-login/?currency=EUR.

  • 404 doesn't imply your site is broken. If someone or a bot is visiting a URL that does not exist and is not intended then 404 is the correct status to return. – Simon Hayter Sep 19 '17 at 11:06
  • agreed, but these pages does not exists and I want to redirect them to home page – Blender For You Sep 19 '17 at 11:07
  • 2
    Your redirecting non relevant pages to the homepage is generally considered bad for SEO and user experience. moz.com/community/q/… just one of thousands that you should read. A 404 does not mean your site is broken, since it is not broken there is nothing to fix. The only time you should use redirect is from a relevant page to another relevant page, and the only time to fix 404's is where your site is causing them and that should be fixed in the code, often never in the htaccess. – Simon Hayter Sep 19 '17 at 11:10
  • 1
    Google views redirects to the home page as soft 404 errors and will still include them in the Google Search Console error report. – Stephen Ostermiller Sep 19 '17 at 16:03
  • 1
    @SimonHayter I also recommend fixing 404s when the user intention is clear even if it isn't your own site that causes the error. For example redirect any common type in traffic mistakes or redirect mangled or broken inbound links where it is obvious which page the link is supposed to point to. – Stephen Ostermiller Sep 19 '17 at 16:06
1

If you want to redirect any page to the home page when it has a currency parameter, you have to change your regular expression that matches the path portion. Currently you are trying to use ^$ which matches an empty path. .* would match "any path":

RewriteEngine On
RewriteCond %{QUERY_STRING} currency=
RewriteRule .* https://www.example.com/ [R=301,L,QSD]

You could have another rewrite rule that for the directory:

RewriteRule \/?newsite12121212121212.* https://www.example.com/ [R=301,L]

As we have said in the comments, it isn't good for SEO to redirect to the home page. Google considers home page redirect to be "soft 404" errors. It will treat them as if you return "404 Page Not Found" status. Redirecting to the home page won't make the errors in Google Search Console go away.

If you actually have a page for st_tour/perma, you should redirect to it instead of the home page. It might require more redirect rules, but both users and search engines will be happier.

If you have never had such a page, then don't try to claim the URL. It may be caused by spam, malware, or a previous spammy site running on your domain name. If you claim those URLs you could be inviting penalties from search engines. Having 404 errors in your crawl report on Google Search Console for pages that shouldn't exist won't hurt your site in any way. John Mueller from Google says so here: https://plus.google.com/+JohnMueller/posts/RMjFPCSs5fm

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.