Problem is, that SEO tools tell us, we have duplicate content with Home Page URL and Home Page URL with country code.

www.XYZ.com www.XYZ.com/de/

What is the easiest and most pragmatic solution to solve this?

Other store views ok as per

www.XYZ.com/en/ www.XYZ.com/es/ and country code needed to added.

But for the main page, I want to have only one main page.

Any hint appreciated.


2 Answers 2


Edit 25/07/2023

I think you can implement rewriteCond to add each store code (that's maybe no the best way but it should work)

Main Post

For my part, I use redirect from .htaccess (for apache server) located under pub/.htaccess to redirect / to /de

RedirectMatch 301 ^/$ /de/

Combined with this i use these conditions to redirect everything to /de/* expect for /de/ and /{adminUrl}/

RewriteCond %{REQUEST_URI} !^/de/
RewriteCond %{REQUEST_URI} !^/{adminUrl}/
RewriteRule ^(.*)$ /de/$1 [R=301,L]

The problem I didn't manage to fix for now is that. If you try access the site with http:// it will redirect to https:// => http://*/de/ => https://*/de/

The module : "mod_rewrite.c" should look like

<IfModule mod_rewrite.c>

    Options +FollowSymLinks
    RewriteEngine on

    ## ...

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l

    ## ...

    RewriteCond %{REQUEST_URI} !^/de/
    RewriteCond %{REQUEST_URI} !^/en/
    RewriteCond %{REQUEST_URI} !^/es/
    RewriteCond %{REQUEST_URI} !^/fr/
    # implement with each store
    # ...
    RewriteCond %{REQUEST_URI} !^/{adminurl}/
    RewriteRule ^(.*)$ /de/$1 [R=301,L]

    RedirectMatch 301 ^/$ /de/

    RewriteRule .* index.php [L]

If you use Nginx it should be something like this

if ($request_filename ~ /){
    rewrite ^ http://example.com/de? permanent;

Maybe some docs that can help you understand nginx https to https Redirect with nginx

In other way you can add in BO of magento under Marketing sections : URL Rewrite a link that redirect / to /de. but idk if that's the best way

  • Unfortunately that did not work as it creates endless redirects with de/de/de :/
    – Ben
    Jul 25, 2023 at 13:24
  • @Ben i updated the answer can you try please ?
    – DJX
    Jul 25, 2023 at 14:05

You will simply add a canonical URL in header for home page, which is just a fancy way of saying, “the URL you want to show up in search.”

The canonical tag looks like this:

<link rel=“canonical” href=“www.XYZ.com” />

Despite the URL the visitor is on, the behind-the-scenes canonical tag on each duplicate URL would point to a single URL.

In theory, this tells the search engines not to index the non-canonical URLs and to assign all other value metrics over to the canonical version.

This works most of the time, but in reality, the search engines only use the canonical tag as a “signal.” They will then choose to apply or ignore it as they see fit.

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.