Score:1

Redirect French homepage (and only FR home page) to English home page

it flag

Using the .htaccess file, I would like to redirect www.example.com/fr/ to www.example.com/ but not other French pages that have the /fr/ root (e.g. www.example.com/fr/page-name)

I've tried using Redirect 301 /fr/ https://example.com/ but that redirects all the French pages to the English versions, which I don't want.

Is there a way around this?

Score:0
kz flag
Redirect 301 /fr/ https://example.com/

The mod_alias Redirect directive is prefix-matching, so it redirects everything that simply starts /fr/ and copies everything after the match onto the end of the target URL. It's great for redirecting entire URL branches (or entire sites), but not for specific URLs.

To redirect a specific URL you need to use RedirectMatch, which matches against a regex, instead of simple prefix-matching.

For example:

RedirectMatch 301 ^/fr/$ https://example.com/

Note that if you have existing mod_rewrite directives (ie. RewriteRule) then you may need to use (or may be preferable to use) mod_rewrite instead here.

Reference:

it flag
Perfect, this works! Thanks!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.