fix some ssl and redirect bugs