我回到问题中包含的链接,并意识到该线程顶部附近的简单案例实际上可以满足我的需要。以下是对我真正有用的:
#in .htaccess
RewriteEngine on
# If an encoded "?" is present in the requested URI, and no unencoded "?" is
# present, then externally redirect to replace the encoded "?" character.
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^?\ ]+)\ HTTP/
RewriteCond %1 ^(([^%]*(\%(25)*([^3].|.[^F]))*)*)\%(25)*3F(.*)$ [NC]
RewriteRule ^. http://www.example.com/percent_fix.php?%7 [NE,R=301,L]
然后在 percent_fix.php
<?php
if($_SERVER['QUERY_STRING'])
{
$new_query=urldecode($_SERVER['QUERY_STRING']);
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com/?'.$new_query);
die();
}
else
{
header('HTTP/1.x 404 Not Found');
//readfile("http://www.example.com/?page=404_error");
die();
}
?>