如何在URL中传递波斯字符串作为参数

如何在URL中传递波斯字符串作为参数

本文介绍了如何在URL中传递波斯字符串作为参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个类似于此模式的URL: www.example.com/ClassName/MethodName/Arg1/Arg2 这也是我的 .htaccess 文件: 上的RewriteEngine RecondCond%{REQUEST_FILENAME}!-f RewriteCond%{REQUEST_FILENAME}! -d RewriteRule ^(。*)$ index.php?rt = $ 1 [L,QSA] ErrorDocument 404 /error404.html 这是我的路由系统: if(empty($ _ GET ['rt'])){ require_once('application / home.php'); }否则{ require_once(’application / search.php’); $ url = rtrim($ _GET [’rt'],‘/’); $ url = explode(’/’,$ url); $ ClassName = array_shift($ url); $ MethodName = array_shift($ url); $ Arg1 = array_shift($ url); $ Arg2 = array_shift($ url); } 现在出了什么问题?好吧,一切都很好..!当我在URL中使用م时,对于每个URL 除外,路由都是完全可以的。 ((م是波斯字符) 例如, www.example.com/ClassName/Methodname/124/روزخوب//罚款 www。 example.com/ClassName/Methodname/254/سلامبر//罚款 //因为URL 因此,当我在URL中使用م时,我将遇到404 Not Found页面: 好吧,我不知道不知道问题出在哪里..你知道吗?我该如何解决?这是编码问题吗?还是什么? 注意:我使用的是Xampp v3.2.1(Apache)。 编辑:如评论中所述,我添加了以下两个示例: <?php $ str = www.example.com/ClassName/Methodname/124/روزخوب; $ url = explode(’/’,$ str); echo< pre>; print_r($ url); / * 数组( [0] => www.example.com [1] => ClassName [2] =>方法名 [3] => 124 [4] =>روزخوب) * / 二:(指向404未找到) <?php $ str = www.example.com/ClassName/Methodname/254/سلامبر; $ url = explode(’/’,$ str); echo< pre>; print_r($ url); / * 数组( [0] => www.example.com [1] => ClassName [2] =>方法名 [3] => 254 [4] =>سلامبر) * / EDIT2:根据一些测试,我发现了应该由我的重写规则调用的脚本( index.php ),它甚至没有被调用。 EDIT3:我在Apache上启用了重写日志记录,当我检查结果时,有一件有趣的事情: (这两个示例与上述示例无关) 工作路由示例: [2016年1月2日星期六:[rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[客户端:: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C:/ xampp / htdocs / myweb /]添加路径信息后缀:C:/ xampp / htdocs / myweb / islamic_sources-> C:/ xampp / htdocs / myweb / islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa,引荐来源:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728 ] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C:/ xampp / htdocs / myweb /]条带-目录前缀:C:/ xampp / htdocs / myweb / islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa-> islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa,参考网址:http:// localhost / myweb / search?s = islamic_sources& q =% D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[客户端:: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C:/ xampp / htdocs / myweb /]将模式'^(。*)$'应用于uri 'islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa',引荐网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475) :[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C:/ xampp / htdocs / myweb /] RewriteCond:input ='C:/ xampp / htdocs / myweb / islamic_sources'pattern ='!-f'=>匹配,引荐来源网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.276918 2016 ] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C :/ xampp / htdocs / myweb /] RewriteCond:input ='C:/ xampp / htdocs / myweb / islamic_sources'pattern ='!-d'=>匹配,引荐来源网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.276918 2016 ] [rewrite:trace2] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C :/ xampp / htdocs / myweb /]重写'islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa'-> 'index.php?rt = islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa',引荐网址:http:// localhost / myweb / search ?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[客户端:: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] split uri = index.php?rt = islamic_sources / sahifeh_sajadiyeh / 1580 / \ \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa-> uri = index.php,args = rt = islamic_sources / sahifeh_sajadiyeh / 1580 / \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa,参考网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[客户端:: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 / initial] [perdir C:/ xampp / htdocs / myweb /]添加-dir前缀:index.php-> C:/xampp/htdocs/myweb/index.php,参考网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [2016年1月2日星期六22:17:00.277919] [重写:trace2] [pid 3188:tid 1728] mod_rewrite.c(475):[客户端:: 1:49413] :: 1--[localhost / sid#c397b0 ] [rid#28661a0 / initial] [perdir C:/ xampp / htdocs / myweb /]删除document_root前缀:C:/xampp/htdocs/myweb/index.php-> /myweb/index.php,参考网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22 :17:00.277919 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#28661a0 /初始] [perdir C:/ xampp / htdocs / myweb /]使用/myweb/index.php [内部重定向]内部重定向,引荐网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3 %D9%84%D8%A7%D9%85 [2016年1月2日星期六22:17:00.277919] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c8b0 / initial / redir#1] [Perdir C:/ xampp / htdocs / myweb /]删除每个目录前缀:C:/ xampp / htdocs / myweb / index.php-> index.php,引荐来源网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17: 00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c8b0 / initial / redir #1] [perdir C:/ xampp / htdocs / myweb /]将模式'^(。*)$'应用于uri'index.php',引荐网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.277919 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475) :[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c8b0 / initial / redir#1] [perdir C:/ xampp / htdocs / myweb /] RewriteCond:input ='C :/xampp/htdocs/myweb/index.php'pattern ='!-f'=>不匹配,引荐来源网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17: 00.277919 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c8b0 / initial / redir #1] [Perdir C:/ xampp / htdocs / myweb /]通过C:/xampp/htdocs/myweb/index.php,引用网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8 %B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c1b8 / initial] [perdir C:/ xampp / htdocs / myweb /]删除每个目录前缀:C:/ xampp / htdocs / myweb / fonts / taha / QuranTaha.woff-> fonts / taha / QuranTaha.woff,参考网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c1b8 / initial] [perdir C:/ xampp / htdocs / myweb /]将模式'^(。*)$'应用于uri'fonts / taha / QuranTaha.woff',引荐网址:http:// localhost / myweb / search?s = islamic_sources&q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17:00.470250 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite。 c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c1b8 / initial] [perdir C:/ xampp / htdocs / myweb /] RewriteCond:input ='C :/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff'pattern ='!-f'=>不匹配,引荐来源网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8%B3%D9%84%D8%A7%D9%85 [Sat Jan 02 22:17: 00.470250 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475):[client :: 1:49413] :: 1--[localhost / sid#c397b0] [rid#286c1b8 / initial] [ perdir C:/ xampp / htdocs / myweb /]通过C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff,引荐网址:http:// localhost / myweb / search?s = islamic_sources& q =%D8 %B3%D9%84%D8%A7%D9%85 无效(重定向至404,找到)样本: [2016年1月2日周六22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712 ] mod_rewrite.c(475):[client :: 1:64955] :: 1--[localhost / sid#c397b0] [rid#83ec138 / initial] [perdir C:/ xampp / htdocs / myweb /]添加路径信息后缀:C:/ xampp / htdocs / myweb / islamic_sources-> C:/ xampp / htdocs / myweb / islamic_sources / sahifeh_sajadiyeh / 306 / \xd9\x85\xd8\xa8 [Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188 :tid 1712] mod_rewrite.c(475):[client :: 1:64955] :: 1--[localhost / sid#c397b0] [rid#83ec138 / initial] [perdir C:/ xampp / htdocs / myweb /]删除每个目录前缀:C:/ xampp / htdocs / myweb / islamic_sources / sahifeh_sajadiyeh / 306 / \xd9\x85\xd8\xa8-> islamic_sources / sahifeh_sajadiyeh / 306 / \xd9\x85\xd8\xa8 [Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475 ):[client :: 1:64955] :: 1--[localhost / sid#c397b0] [rid#83ec138 / initial] [perdir C:/ xampp / htdocs / myweb /]应用模式'^(。*)$ '到uri'islamic_sources / sahifeh_sajadiyeh / 306 / \xd9\x85\xd8\xa8' [Sat Jan 02 22:07:09.734092 2016] [rewrite:trace1] [pid 3188:tid 1712] mod_rewrite.c(475):[client :: 1:64955] :: 1--[localhost / sid#c397b0] [rid#83ec138 / initial] [perdir C:/ xampp / htdocs / myweb /]通过C传递: / xampp / htdocs / myweb / islamic_sources 有趣点:好的,该波斯字符串将如下所示:(仅解码): %D8%B3%D9%84%D8% A7%D9%85 但是当找不到404路由时,波斯字符串将如下所示: \xd9\x86\xd8\xa8\xd9\x88\xd8\xaa 似乎有两种不同的编码方式。.解决方案您可以尝试使用此变体更好: RewriteRule ^([\s\S] *)$ index.php?rt = $ 1 [L, B,QSA] 此更改是: 1:使用 [\s\S] 绝对匹配任何字符,而不是。,但匹配除换行符以外的任何内容。 尽管您通常不会期望换行符(%0A )在您的URL中,我怀疑Apache的正则表达式匹配器将您的输入路径视为采用ISO-8859-1编码。 IRI字符U + 0645阿拉伯字母Meem م UTF-8-URL编码为URI序列%D9%85 ,而字节0xD9可以ISO-8859-1、0x85解码为U + 0085下一行(NEL),这是不受欢迎的传统控制字符,通常被视为换行符。因此,如果发生这种情况,表达式。* 将与之不匹配。 说了这么多,这就是相当理论上,因为您的示例对我来说是原样,在旧版XAMPP 1.8.2上我躺在WinXP上。 2:使用 [B] 重写标志 ,以确保所有字节均以正确的URL编码形式在参数中传递。 否则,在Apache将查询字符串发送到的情况下,非ASCII字符会中断。 PHP通过Windows环境变量。 Windows环境是Unicode,因此Apache必须在写入时对字节进行解码,而PHP在读取时必须再次对字节进行编码,不幸的是这些编码不匹配。 Apache使用ISO-8859-1,PHP(通过C stdlib)使用ANSI代码页,这取决于Windows安装的区域设置。在西方安装中,您将获得代码页1252,该代码页接近ISO-8859-1,因此只有某些字节是错误的(同样,这包括م);在具有其他ANSI代码页的其他语言环境中,所有非ASCII字符都将完全错误。 这不一定适用于您,因为XAMPP使用的是mod_php,无需使用环境来传递字符串。但这将在其他托管环境中有所作为。无论如何,在没有 [B] 的情况下,您会在字符串中找到URL特殊字符(&号,加上百分号)会破坏查询解析器。 I have a URL like this pattern:www.example.com/ClassName/MethodName/Arg1/Arg2Also here is my .htaccess file:RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]ErrorDocument 404 /error404.htmlAnd this is my routing system:if (empty($_GET['rt'])) { require_once('application/home.php');} else { require_once('application/search.php'); $url = rtrim ($_GET['rt'], '/'); $url = explode('/', $url); $ClassName = array_shift($url); $MethodName = array_shift($url); $Arg1 = array_shift($url); $Arg2 = array_shift($url);}Now what is the problem? Well, Everything is fine ..! Routing is completely fine for every URLs except when I use م in the URL. (م is a Persian character)For e.g.www.example.com/ClassName/Methodname/124/روز خوب // it is finewww.example.com/ClassName/Methodname/254/سلام بر // it isn't fine// because there is م ^ in the URLSo when I use م in the URL, I will faced with 404 Not Found page:Well, I don't know that problem comes from where .. do you know? And how can I fix it? Is it a encoding issue? Or what?Note: I use Xampp v3.2.1 (apache).EDIT: As mentioned in the comment, I add these two examples:<?php$str = "www.example.com/ClassName/Methodname/124/روز خوب";$url = explode('/', $str);echo "<pre>";print_r($url);/*Array( [0] => www.example.com [1] => ClassName [2] => Methodname [3] => 124 [4] => روز خوب)*/Two: (this directs to 404 Not Found)<?php$str = "www.example.com/ClassName/Methodname/254/سلام بر";$url = explode('/', $str);echo "<pre>";print_r($url);/*Array( [0] => www.example.com [1] => ClassName [2] => Methodname [3] => 254 [4] => سلام بر)*/EDIT2: According to a few tests, I figured out the script that should get called by my rewriting rules (index.php), it even doesn't get call.EDIT3: I enabled rewrite logging on Apache and when I check the result, there is a interesting thing:(These two samples aren't related to the above examples)Working routing sample:[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] add path info postfix: C:/xampp/htdocs/myweb/islamic_sources -> C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa -> islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa', referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/islamic_sources' pattern='!-f' => matched, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/islamic_sources' pattern='!-d' => matched, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace2] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] rewrite 'islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa' -> 'index.php?rt=islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa', referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.276918 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] split uri=index.php?rt=islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa -> uri=index.php, args=rt=islamic_sources/sahifeh_sajadiyeh/1580/\xd9\x86\xd8\xa8\xd9\x88\xd8\xaa, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] add per-dir prefix: index.php -> C:/xampp/htdocs/myweb/index.php, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace2] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] strip document_root prefix: C:/xampp/htdocs/myweb/index.php -> /myweb/index.php, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#28661a0/initial] [perdir C:/xampp/htdocs/myweb/] internal redirect with /myweb/index.php [INTERNAL REDIRECT], referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/index.php -> index.php, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'index.php', referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/index.php' pattern='!-f' => not-matched, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.277919 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c8b0/initial/redir#1] [perdir C:/xampp/htdocs/myweb/] pass through C:/xampp/htdocs/myweb/index.php, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.470250 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff -> fonts/taha/QuranTaha.woff, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.470250 2016] [rewrite:trace3] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'fonts/taha/QuranTaha.woff', referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.470250 2016] [rewrite:trace4] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] RewriteCond: input='C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff' pattern='!-f' => not-matched, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85[Sat Jan 02 22:17:00.470250 2016] [rewrite:trace1] [pid 3188:tid 1728] mod_rewrite.c(475): [client ::1:49413] ::1 - - [localhost/sid#c397b0][rid#286c1b8/initial] [perdir C:/xampp/htdocs/myweb/] pass through C:/xampp/htdocs/myweb/fonts/taha/QuranTaha.woff, referer: http://localhost/myweb/search?s=islamic_sources&q=%D8%B3%D9%84%D8%A7%D9%85Not working (redirects to 404 not found) sample:[Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] add path info postfix: C:/xampp/htdocs/myweb/islamic_sources -> C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8[Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] strip per-dir prefix: C:/xampp/htdocs/myweb/islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8 -> islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8[Sat Jan 02 22:07:09.734092 2016] [rewrite:trace3] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] applying pattern '^(.*)$' to uri 'islamic_sources/sahifeh_sajadiyeh/306/\xd9\x85\xd8\xa8'[Sat Jan 02 22:07:09.734092 2016] [rewrite:trace1] [pid 3188:tid 1712] mod_rewrite.c(475): [client ::1:64955] ::1 - - [localhost/sid#c397b0][rid#83ec138/initial] [perdir C:/xampp/htdocs/myweb/] pass through C:/xampp/htdocs/myweb/islamic_sourcesInteresting point: when routing is fine, that Persian string will be like this: (just decode):%D8%B3%D9%84%D8%A7%D9%85But when routing is 404 not found, the Persian string will be like this:\xd9\x86\xd8\xa8\xd9\x88\xd8\xaaSeems there is two different kinds of encoding .. 解决方案 You could try this variant that may work better:RewriteRule ^([\s\S]*)$ index.php?rt=$1 [L,B,QSA]The changes that this makes are:1: using [\s\S] to match absolutely any character, instead of . which matches anything but a newline.Though you wouldn't normally expect newline (%0A) to be in your URLs, my suspicion is that Apache's regexp matcher is treating your input path as being in the ISO-8859-1 encoding.The IRI character U+0645 Arabic Letter Meem م UTF-8-URL-encodes to URI sequence %D9%85, and whilst byte 0xD9 is okay in ISO-8859-1, 0x85 decodes to U+0085 Next Line (NEL), an undesirable legacy control character that often counts as a newline. So if that happened, the expression .* wouldn't match it.Having said all that, this is quite theoretical as your example works as-is for me, on an old XAMPP 1.8.2 I had lying about on WinXP.2: using the [B] rewrite flag, to ensure all bytes are passed in correctly-URL-encoded form in the parameter.Otherwise, non-ASCII characters would break for situations where Apache sends the query string to PHP through Windows environment variables. The Windows environment is Unicode, so Apache has to decode the bytes on writing and PHP has to encode them again on reading, and unfortunately those encodings don't match.Apache uses ISO-8859-1 and PHP (via C stdlib) uses the ANSI code page, which depends on the locale of the Windows installation. On a Western install, you get code page 1252, which is close to ISO-8859-1 so only some of the bytes will be wrong (again, this includes the 0x85 in م); on other locales with other ANSI code pages all the non-ASCII characters will be wildly wrong.This doesn't necessarily apply to you as XAMPP is using mod_php, which doesn't need to use the environment to pass strings. But it would make a difference in other hosting environments. In any case, without [B] you'll find URL-special characters in the string (ampersand, plus, percent) break the query parser. 这篇关于如何在URL中传递波斯字符串作为参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-02 02:24