Forum Moderators: phranque
Problem is we rewrite the URLs from our cms
example.com/?id=folder/something it rewritten to
example.com/folder/something.htm
# Alternate rule 1 - Forbid any client requests with query strings
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?\ ]*\?[^\ ]*\ HTTP/
RewriteRule ^ - [F]
#
# Alternate rule 2 - Redirect client requests with query strings to remove the query string
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?\ ]*\?([^\ ]*)\ HTTP/
RewriteRule ^(.*)$ http://www.example.com/$1? [R=301,L]
$file_name = $_SERVER['SCRIPT_NAME']; $query_string = $_SERVER['QUERY_STRING']; function rebuildQueryString($ignore=array()) { $ignore = array_flip($ignore); $get = array(); foreach ($_GET as $key=>$val) if (isset($ignore[$key])) { $get[$key] = $key."=".urlencode($val); } return implode("&", $get); } if($query_string == ''){ $full_url = 'http://www.example.com'.$file_name; } else { $query_string = rebuildQueryString(array("blah1", "blah2", "blah3")); $full_url = 'http://www.example.com'.$file_name.'?'.$query_string;} }