From 9fbe80d3e352146d3fc6716fe35a47858bcb81ed Mon Sep 17 00:00:00 2001 From: "Cathy J. Fitzpatrick" Date: Thu, 30 May 2013 18:09:09 -0500 Subject: [PATCH] Better handling of HTTPS redirects --- .htaccess | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.htaccess b/.htaccess index 6af91db12..dfac5430d 100644 --- a/.htaccess +++ b/.htaccess @@ -50,7 +50,17 @@ RewriteCond %{ENV:SCRIPT_URL} ^/(lobby/?)?$ RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^https?:\/\/([a-z0-9-]+.)?(pokemonshowdown\.com|appjs) RewriteCond %{REMOTE_ADDR} !^127\.0\.0\.1$ -RewriteRule ^.* http%{ENV:P_SUFFIX}://pokemonshowdown.com/ [R=303,L] +RewriteRule .* - [E=LOBBY_REDIRECT:1] + +RewriteCond %{ENV:LOBBY_REDIRECT}%{ENV:P_SUFFIX} =1 +RewriteRule ^.* http://pokemonshowdown.com/ [R=303,L] + +RewriteCond %{ENV:LOBBY_REDIRECT}%{ENV:P_SUFFIX} =1s +RewriteRule ^.* http://pokemonshowdown.com/secure [R=303,L] + +RewriteCond %{HTTP_REFERER} =http://pokemonshowdown.com/secure +RewriteCond %{ENV:P_SUFFIX} !=s +RewriteRule ^(.*) https://play.pokemonshowdown.com/$1 RewriteRule ^replay/battle-([A-Za-z0-9-]+)$ http%{ENV:P_SUFFIX}://pokemonshowdown.com/replay/$1 [R=302,L] RewriteRule ^replay/turn_(.+)\.png$ replay/turn-image.php?data=$1 [L,QSA]