iFaZe/MerpMaster/master/static/.htaccess - Htaccess File

iFaZe/MerpMaster/master/static/.htaccess

AddType text/plain .phps
AddType application/x-tgz .tgz
AddType application/x-chrome-extension .crx
AddType application/x-web-app-manifest+json .webapp

<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP:X-Forwarded-Proto} ^https$
RewriteRule ^(.*) - [E=P_SUFFIX:s]

# Send bingbot a `noindex` header on every page.
RewriteCond %{HTTP_USER_AGENT} bingbot
RewriteRule ^(.*) - [E=BINGBOT:1]
Header set X-Robots-Tag "noindex" env=BINGBOT
Header unset Vary env=BINGBOT

RewriteCond %{HTTP_HOST} ^www.play.pokemonshowdown.com$ [NC]
RewriteRule ^(.*) http%{ENV:P_SUFFIX}://play.pokemonshowdown.com/$1 [R=301,L]

RewriteRule ^style/font/.*?.(eot|svg|ttf|woff)$ - [E=SAFE_RESOURCE:1]
Header set Access-Control-Allow-Origin * env=SAFE_RESOURCE

# Redirect old battles to their corresponding replay
RewriteCond %{HTTP_HOST} ^play.pokemonshowdown.com$ [NC]
RewriteRule ^battle-([a-z0-9]+-3[0-3][0-9]{6})$ http%{ENV:P_SUFFIX}://pokemonshowdown.com/replay/$1 [R=302,L]
RewriteCond %{HTTP_HOST} ^play.pokemonshowdown.com$ [NC]
RewriteRule ^battle-([a-z0-9]+-?[1-2][0-9]{7})$ http%{ENV:P_SUFFIX}://pokemonshowdown.com/replay/$1 [R=302,L]
RewriteCond %{HTTP_HOST} ^play.pokemonshowdown.com$ [NC]
RewriteRule ^battle-([a-z]+[0-9]{1,7})$ http%{ENV:P_SUFFIX}://pokemonshowdown.com/replay/$1 [R=302,L]

# TODO: fix bug where you can't join lobby directly
RewriteRule ^lobby/?$ / [R=301,L]

# roomid with a slash after it: remove the slash, unless the roomid
# is also an actual directory
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
RewriteRule ^([A-Za-z0-9][A-Za-z0-9-]*)/$ /$1 [R=301,L]

#RewriteCond %{ENV:P_SUFFIX} =s
#RewriteRule ^([A-Za-z0-9-]*)$ http://play.pokemonshowdown.com/$1 [L=R03,L]

# Anything that looks like a roomid: connect to the server
RewriteRule ^$ - [E=INDEX_PAGE:1]
RewriteRule ^([A-Za-z0-9][A-Za-z0-9-]*)$ ./ [L,E=INDEX_PAGE:1]

# Headers for the index page.
Header set Cache-Control "no-cache, no-store, must-revalidate" env=INDEX_PAGE
Header set Pragma "no-cache" env=INDEX_PAGE
Header set Expires "0" env=INDEX_PAGE
Header set X-Robots-Tag "noindex" env=INDEX_PAGE

# No direct linking to the lobby.
RewriteCond %{ENV:SCRIPT_URL} ^/(lobby/?)?$
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://([a-z0-9-]+.)?(pokemonshowdown.com|appjs)
RewriteCond %{HTTP_HOST} ^play.pokemonshowdown.com$
RewriteCond %{REMOTE_ADDR} !=127.0.0.1
RewriteCond %{HTTP:CF-Connecting-IP} !=173.252.196.254
RewriteCond %{HTTP:CF-Connecting-IP} !=198.27.67.31
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]

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]

RewriteCond %{QUERY_STRING} !output=html
RewriteRule ^ladder.php$ http%{ENV:P_SUFFIX}://pokemonshowdown.com/ladder/ [R=301,L]

RewriteRule ^~~([^:/]*)(:[0-9]*)?/action.php$ action.php?serverid=$1 [L,QSA]
RewriteRule ^~~([^:/]*)(/.*)?$ http://$1.psim.us$2 [R=301,L]
RewriteRule ^~~([^:/]*):([0-9]*)(/.*)?$ http://$1-$2.psim.us$3 [R=301,L]

RewriteRule ^backup/ - [F]
RewriteRule ^.git/ - [F]
RewriteRule ^lib/ - [F]
RewriteRule ^githooks/ - [F]

RewriteRule ^.gitignore$ - [F]
RewriteRule ^README.md$ - [F]
RewriteRule ^index.template.html$ - [F]
RewriteRule ^testclient.html$ - [F]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(apple-touch-icon-precomposed.png)$ - [R=404,L]

</IfModule>

On Github License

Files

Download PDF of Htaccess file
DOCUMENT_ROOT, ENV, HTTP_HOST, HTTP_REFERER, HTTP_USER_AGENT, no-cache, P_SUFFIX, Pragma, QUERY_STRING, REMOTE_ADDR, REQUEST_FILENAME, SCRIPT_URL, X-Forwarded-Proto

Comments

Apache