2012-02-13 25 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