.HTACCESS Unicode识别/编码 [英] .HTACCESS Unicode Recignisition/Encoding

查看:111
本文介绍了.HTACCESS Unicode识别/编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的.htaccess中的URL快捷方式有问题。

I am having a problem with my URL Shorthands in my .htaccess.

就是说,此代码(现在已经很旧了)一切正常...

Namely, everything works fine with this (now old) code...

# URL ShortCut Maker.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} .(.+)$
RewriteRule ^(.) ?open=encyclopedia&letter=$1&term=%1 [B,L,NC]

网址正确地为 example.com/Modesty (它显示的页面就像该网址为 /?open = encyclopedia& letter = m& term =谦虚), 但是 ,当我输入以下内容时会出现问题:
example.com/Šanti

example.com/Đin

example.com/ Žal

example.com/Čakra

示例.com /Ćof ...

...如果我输入这些URL中的任何一个,则显示该页面就像输入以下内容:

?open =百科全书,而不是

?open = encyclopedia& letter =Š& term =Šanti

It shows URL correctly as example.com/Modesty (it shows the page as if the URL would be /?open=encyclopedia&letter=m&term=modesty), but the problem occurs when I enter: example.com/Šanti, or
example.com/Đin, or
example.com/Žal,
example.com/Čakra, or
example.com/Ćof...
...if I enter any of these URLs - it shows the page as if I would enter:
?open=encyclopedia and not as
?open=encyclopedia&letter=Š&term=Šanti

编辑:有问题的非英语字母。

任何解决方案?

推荐答案

您可以使用以下规则更改现有规则:

You can change your existing rule with rule:

RewriteEngine On

RewriteBase /

# executes repeatedly as long as there are more than 1 spaces in URI
RewriteRule "^(\S*)\s+(\S* .*)$" $1+$2 [N,NE]

# executes when there is exactly 1 space in URI
RewriteRule "^(\S*)\s(\S*)$" $1+$2 [L,R=302,NE]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule ^([A-Z](?:[^\x00-\x7F]+|[A-Z])?).*$ ?open=encyclopedia&letter=$1&term=$0 [B,L,QSA]

RewriteRule ^([^\x00-\x7F]+).*$ ?open=encyclopedia&letter=$1&term=$0 [B,L,QSA]

否定字符类 [^ \x00-\x7F] 匹配ASCII范围以外的任何字符。

Negated character class [^\x00-\x7F] matches any character outside ASCII range.

这篇关于.HTACCESS Unicode识别/编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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