3

I have the following situation:

  1. I have a new website like this: https://www.example.com
  2. When you access to my website, it automatically redirects (302 redirection) to its English language page version like this: https://www.example.com/en/index.php

But I have an issue, because Google only indexes the page https://www.example.com/en/index.php And Google doesn't index the actual URL of the website https://www.example.com

I have added the following meta/canonical to https://www.example.com/en/index.php, but it doesn't solve the Google index issue:

<link rel="canonical" href="https://www.example.com">

1
  • 1
    You should never show index.php in the URL to users. That document is the default document for the directory and it is meant to be hidden. I'll bet redirecting to https://www.example.com/en/ would work just fine and it would be a much cleaner URL for Google to index. Aug 6, 2022 at 9:31

1 Answer 1

1

By putting a redirect you are telling Google and any other search engine that the page you want to show is the second one (the target of your redirect).

Consider this example:

  • Original page: https://www.example.com/this-content-is-obsolete
  • Redirects to: https://www.example.com/this-content-is-current

It wouldn't make sense to show in the SERPs the first one, as it's obsolete. The correct way is to show the second page, where the user redirects.

In addition, the canonical tag you've implemented is causing a redirect loop. However, Google is smart enough to handle it correctly.

To get the results you want, you can either:

  1. Redirect from https://www.example.com/en/index.php to https://www.example.com/ and serve your homepage on that URL (which is the default).
  2. If your objective is to serve different languages, implement a form of automatic redirection based on the browser language (however, you'll still need to have some content on https://www.example.com/ if you want it to be indexed).
2
  • But it depends of the type of redirect. When you access to a web page, the header of the http response indicates if it comes from a 302 redirect. And google takes 302 redirects only as temporary redirects.
    – Christian
    Jul 9, 2022 at 16:13
  • 1
    Google doesn't usually index redirecting URLs. It doesn't matter if the redirect is a 301 or a 302. Google will prefer to index the target of the redirect. When you are redirecting to add a language to the URL, Google wants to be sure that they are sending English users to /en/ and not to / which might redirect to any language. Aug 6, 2022 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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