if( count( $_POST ) < 1 ) {
// determine if this was a secure request - we use a non standard HTTPS port so the SERVER_HTTPS_PORT define should always be used in place of 443
$protocol = $_SERVER['SERVER_PORT'] == SERVER_HTTPS_PORT ? 'https' : 'http';
header( "HTTP/1.0 301 Moved Permanently" );
header( "Status: 301" ); // this is for chrome compliance
header( "Location: $protocol://".CLIENT_DOMAIN."{$_SERVER['REQUEST_URI']}" );
session_write_close();
exit;
}
可以使用 .htaccess 规则重写此功能吗?
逻辑:
如果不是 POST 请求,则通过发出 301 标头和状态重定向到具有整个查询字符串的等效页面,同时保持协议。