2012-02-13 52 views
0

我想在.htaccess中重寫時將單個小寫字母轉換爲大寫字母。例如,我有這樣的在htaccess中轉換URL中的單個字符重寫

網址:www.domain.com/?country=CUoatia

,我想它成爲:www.domain.com/Croatia

此外,大寫字母「U」將被轉換爲「R」。

我可以用下面的代碼實現www.domain.com/CUoatia

RewriteCond %{QUERY_STRING} ^country=(.*) 
RewriteRule ^$ %1? [R=301] 

但我不知道該如何改變這種「U」字,以「R」。

回答

1

你可以試着改變你的規則:

# Replace all capital U in query string 
RewriteCond %{QUERY_STRING} ^(.*)U(.*)$ 
RewriteRule ^(.*)$ /$1?%1r%2 [L] 

# Make sure there are no capital U in the query string 
RewriteCond %{QUERY_STRING} !U 
RewriteCond %{QUERY_STRING} ^country=(.*) 
RewriteRule ^$ %1? [R=301] 
+0

謝謝!稍後再試! :) – 2012-02-13 08:35:36