Search code examples
.htaccesshttp-redirecthttp-status-code-301

.htaccess 301 redirect not redirecting to the French urls properly


I am using a 301 redirect command in .htaccess file

Redirect 301 /fr/emergency http://www.sitename.com/fr/d’urgence

But on redirection the url has turned out to be http://www.sitename.com/fr/d%92urgence and shows a page not found error.

The requirement is that it needs to come as http://www.sitename.com/fr/d’urgence itself.

Any idea what needs to be corrected and where?


Solution

  • The string should be encoded in UTF-8 and then percent encoded. You should never use non-ASCII characters in a URL sent over the wire (at least, not yet... someday), and this is the way around it.

    Redirect 301 /fr/emergency http://www.sitename.com/fr/d%E2%80%99urgence
    

    A web browser will still display it as d’urgence, the user will never see the percent-encoded version. This assumes that the character is actually supposed to be U+2019 "right single quotation mark" and not U+0027 "apostrophe".