在我的网站上,我有以下链接:
site.com/search.php?str=СТРОКА
site.com/search.php?str=Строка
我想让它们像:
site.com/search.php?str=строка
即。我想小写{QUERY_STRING}
我怎么能这样做? 我无法使用RewriteMap!
提前致谢!
答案 0 :(得分:0)
如果你有像ciryllic query_string这样的链接:
site.com/search.php?str=СТРОКА
site.com/search.php?str=Строка
你想让它们像小写它
site.com/search.php?str=строка
您无法使用RewriteMap,请按照以下步骤操作:
1)将这些行添加到.htaccess:
RewriteCond %{QUERY_STRING} %D0%([AF].)
RewriteRule (.*) rewrite-strtolower.php?rewrite-strtolower-url=$1 [QSA,L]
%D0%([9A]。)|(81) - 检测[А-Я]
2)将rewrite-strtolower.php放置在几乎.htacces
<?php header('Content-Type: text/html; charset=utf-8');
function myUrlEncode($string) {
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
return str_replace($entities, $replacements, urlencode($string));
}
if(isset($_GET['rewrite-strtolower-url'])) {
$url = $_GET['rewrite-strtolower-url'];
unset($_GET['rewrite-strtolower-url']);
$params = http_build_query($_GET);
if(strlen($params)) {
$params = '?' . myUrlEncode(mb_strtolower(urldecode($params),"UTF-8"));
}
header('Location: http://' . $_SERVER['HTTP_HOST'] . '/' . $url . $params, true, 301);
exit;
}
header("HTTP/1.0 404 Not Found");
die('Unable to convert the URL to lowercase. You must supply a URL to work upon.');
?>
3)利润