2011-02-14 58 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