2011-02-14 28 views
0

我的共享主机帐户存在问题。 apache服务器我使用争夺utf8所以我不能使用希伯来语/阿拉伯语在URL如www.mydomain.com/אבא。php如何在.htaccess中制作简单的Mod_Rewrite

所以我想知道我该怎么做,如果有人问对于页: www.mydomain.com/%D7%90%D7%91%D7%90.php

他会得到页面:www.mydomain.com/ D790D791D790.php(没有百分比) 但他的浏览器网址会显示他要求的第一页(没有重定向)。

我想在.htaccess中使用mod_rewrite,但不知道如何解决这个问题。 请帮助你们,这是我的911。

回答

0

我一直在想这个问题,除非你知道有多少套(在你的例子中是6套),我不认为会有一种非常优雅的方式来做到这一点。一种解决方案可能是使用一个相当模糊的重写RewriteRule ^(.*?%.*?)\.php$ foo.php?bar=$1然后用PHP处理数据,这里有更多的选项和更多的灵活性。正则表达式的

详情:

^.*?%.*?\.php$ 

Options: case insensitive 

Assert position at the beginning of the string «^» 
Match any single character that is not a line break character «.*?» 
    Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?» 
Match the character “%” literally «%» 
Match any single character that is not a line break character «.*?» 
    Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?» 
Match the character “.” literally «\.» 
Match the characters “php” literally «php» 
Assert position at the end of the string (or before the line break at the end of the string, if any) «$» 

Created with RegexBuddy 
+0

Unkwntech没有办法简单地匹配%?用什么也不用,甚至用一个+或一个破折号来代替它? – Tom 2011-02-14 01:05:25