fixed multisite rewrite function