25090

Redirection rules with special characters

I want to use redirect 301 rules (i.e. I hope to be able to avoid rewriting rules) to redirect URLs that contain special characters (like é, à ,...) like for instance

redirect 301 /éxàmple http://mydomain.com/example

However, simply adding this doesn't work. Any suggestions?

Answer1:

<strong>How to troubleshoot this on a Windows system</strong>

On Windows, you can use Notepad++ to enter Unicode characters correctly. After launching Notepad++, select 'Encoding in UTF-8 without BOM' from the 'Encoding' menu, then type your Unicode characters and save the file.

To make sure that the characters have been saved properly, download a hex editor for Windows and make sure that é is saved as c3 89 and à is saved as c3 a0.

<strong>Previous response where I assumed that you are on a Linux system</strong>

Most likely the Unicode characters have not been saved properly in .htaccess file.

What do you get when you try this command:

grep -o .x.mple .htaccess | od -t x1 -c

You should get this if your Unicode characters are saved correctly.

0000000 c3 a9 78 c3 a0 6d 70 6c 65 0a 65 78 61 6d 70 6c 303 251 x 303 240 m p l e \n e x a m p l 0000020 65 0a e \n 0000022

If you have xxd or hd installed, you can get a neater output to do your troubleshooting:

$ grep -o .x.mple .htaccess | xxd -g1 0000000: c3 a9 78 c3 a0 6d 70 6c 65 0a 65 78 61 6d 70 6c ..x..mple.exampl 0000010: 65 0a e.

In all the outputs you can see that é is saved as the binary numbers: c3 89. You can see from http://www.fileformat.info/info/unicode/char/e9/index.htm that the é when encoded in UTF-8 is indeed two-bytes: 0xC3 and 0xA9.

Similarly, à in UTF-8 format is: 0xC3 0xA0. See http://www.fileformat.info/info/unicode/char/e0/index.htm. You can see these codes in the output as well.

Answer2:

These should work, but it depends on some things that you have to check as a checklit:

    <li>Do you have mod_alias enabled? If not, you should run a2enmod mod_alias</li> <li>Do you have some redirection to your example page? (Redirections are applied before aliases)</li> </ul>

    Then, instead of converting it to UTF-8, you can try to put the characters as they're encoded by browsers, for example %C3%A9 for é, etc.

Recommend

  • inserting hex value into mysql
  • How do I write to registers in hardware using Python?
  • Matplotlib: Custom colormap with three colors [duplicate]
  • HTML code to upload images
  • NSMutableArray Access Issue
  • Nodejs bluebird promise fails while processing image
  • remove unicode characters but keep all special and English characters with preg_replace
  • Lua: Line breaks in strings
  • C#: Import/Export Settings into/from a File
  • Is there a way to save the selected text and highlight it again once the page is refreshed?
  • Clarification on min distance on LocationManager.requestLocationUpdates method, min Distance paramet
  • saving file generated by TCPDF
  • JBoss External Properties Files in Classpath
  • How can I set a binding to a Combox in a UserControl?
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • AJAX Html Editor Extender upload image appearing blank
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • Content-Length header not returned from Pylons response
  • Python urlparse: small issue
  • Jquery UI tool tip close icon
  • D3 nodes and links from JSON with nested arrays of children
  • Encrypt data by using a public key in c# and decrypt data by using a private key in php
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • Can I make an Android app that runs a web view in Chrome 39?
  • In LanguageTool, how do you create a dictionary and use it for spell checking?
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to format a variable of double type
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • How do I configure my settings file to work with unit tests?
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs