有特殊字符重定向规则 [英] Redirection rules with special characters

查看:416
本文介绍了有特殊字符重定向规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用301重定向规则(即我希望能避免重写规则)重定向比如像包含特殊字符的URL(如E,A,...)

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

重定向301 /例如 http://mydomain.com/example

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

然而,简单地增加这不起作用。有什么建议么?

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

推荐答案

如何解决这个Windows系统上的

在Windows中,可以用记事本+ +正确输入统一code字符。启动记事本+ +后,从编码菜单中选择使用UTF-8编码没有BOM,然后键入您的Uni code字符和保存文件。

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.

要确保该字符被正确保存,下载一个十六进制编辑器的Windows,并确保é另存为 C3 89 A 另存为 C3 A0

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.

previous回应,我认为你是在Linux系统上

最有可能的统一code字没有被正确保存在.htaccess文件。

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

您应该如果你的Uni code字符都正确保存得到这个。

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

如果你有 XXD HD 安装,你可以得到一个整洁的输出做故障排除:

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.

在所有的输出,你可以看到,é保存为二进制数: C3 89 。您可以从 http://www.fileformat.info见/info/uni$c$c/char/e9/index.htm é当EN codeD的UTF-8的确是两字节:0xC3和0xA9

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.

同样, A 以UTF-8格式是:0xC3 0XA0。请参见 http://www.fileformat.info/info/ UNI code /炭/ E0 / index.htm的。你可以看到,以及在输出C $ CS这些$。

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.

这篇关于有特殊字符重定向规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆