Unify domain names in README
[stouyapi.git] / www / .htaccess
1 #no iso-2022-cn charset for "com.cis.ouya.oth.htm"
2 #"RemoveCharset" does not work, so we have to override with AddCharset
3 AddCharset UTF-8 .iso2022-cn .cis
4 #Fix game/art.var.pgo.htm
5 AddHandler default-handler .var
6
7 DirectorySlash Off
8
9 RewriteEngine on
10 RewriteBase /
11
12 <Files "firmware_builds">
13     ExpiresActive On
14     ExpiresDefault "access plus 1 day"
15 </Files>
16
17 #rewrite details GET parameter
18 RewriteCond %{QUERY_STRING} ^app=([^&]+)
19 RewriteCond %{DOCUMENT_ROOT}/api/v1/details-data/%1.json -f
20 RewriteRule ^api/v1/details /api/v1/details-data/%1.json? [END]
21
22 # details for unknown apps. Also see .htaccess in the dummy dir
23 RewriteRule ^api/v1/details /api/v1/details-dummy/404? [END]
24
25 RewriteRule ^api/v1/apps/(.*)/download$ /api/v1/apps/$1-download.json? [END]
26 RewriteRule ^api/v1/apps/(.*)$ /api/v1/apps/$1.json? [END]
27
28 #rewrite developer products "only" GET parameter
29 RewriteCond %{QUERY_STRING} &only=([^&]+)
30 RewriteCond %{DOCUMENT_ROOT}/api/v1/developers/$1/products/%1.json -f
31 RewriteRule ^api/v1/developers/(.+)/products/ /api/v1/developers/$1/products/%1.json? [END]
32
33 #discover homepage
34 RewriteCond %{HTTP_USER_AGENT} "Forge"
35 RewriteRule ^api/v1/discover/?$ /api/v1/discover-data/discover.forge.json [END]
36
37 RewriteRule ^api/v1/discover/?$ /api/v1/discover-data/discover.json [END]
38
39 #discover category
40 RewriteCond %{HTTP_USER_AGENT} "Forge"
41 RewriteCond %{REQUEST_URI} ^/api/v1/discover/(.+)$
42 RewriteCond %{DOCUMENT_ROOT}/api/v1/discover-data/$1.forge.json -f
43 RewriteRule ^api/v1/discover/(.+)$ /api/v1/discover-data/$1.forge.json [END]
44
45 RewriteRule ^api/v1/discover/(.+)$ /api/v1/discover-data/$1.json [END]
46
47 #if directoryslash is on, gamers gets redirected to gamers/ (dir index)
48 # the ouya registration does not support redirects there
49 #TODO: Use that only for the api/v1/gamers path, not for all
50 ErrorDocument 400 /api/v1/gamers/register-error.json
51 RewriteRule ^api/v1/gamers$ /api/v1/gamers/register-error.json [R=400,END]
52 RewriteRule ^api/razer/gamer$ /api/v1/gamers/register-error.json [R=400,END]
53
54 #prevent redirect from gamers/me to gamers/me/
55 <Files "me">
56     DirectorySlash Off
57 </Files>
58
59 #Disable the next three lines to have static usernames only
60 RewriteRule ^api/razer/session$ /api/razer/session.php [END]
61 RewriteRule ^api/v1/gamers/me$ /api/v1/gamers/me.php [END]
62 RewriteRule ^api/v1/sessions$ /api/v1/sessions.php [END]
63
64 RewriteRule ^api/v1/gamers/me$ /api/v1/gamers/me.json [END]
65
66 #partner builds
67 RewriteCond %{HTTP_USER_AGENT} "razer/pearlyn/pearlyn"
68 RewriteRule ^api/v1/partner_builds$ /api/v1/partner_builds.razer-forge-tv.json [END]
69
70 RewriteRule ^api/v1/partner_builds$ /api/v1/partner_builds.json [END]
71
72 #purchased games/products
73 # active buy requests
74 RewriteCond %{REQUEST_METHOD} POST
75 RewriteRule ^api/v1/games/(.+)/purchases?$ /api/v1/games/purchase.php [END]
76
77 RewriteCond %{REQUEST_FILENAME} !-f
78 RewriteRule ^api/v1/games/(.+)/purchases?$ /api/v1/games/purchases-empty.json [END]
79
80 #search
81 # q is first parameter
82 RewriteCond %{QUERY_STRING} ^q=([^&]+)
83 RewriteCond %{DOCUMENT_ROOT}/api/v1/search-data/%1.json -f
84 RewriteRule ^api/v1/search /api/v1/search-data/%1.json? [END]
85 # q is not the first parameter
86 RewriteCond %{QUERY_STRING} &q=([^&]+)
87 RewriteCond %{DOCUMENT_ROOT}/api/v1/search-data/%1.json -f
88 RewriteRule ^api/v1/search /api/v1/search-data/%1.json? [END]
89
90 # for http://clients3.google.com/generate_204
91 RewriteRule ^generate_204$ /api/v1/status
92
93 #this one wants a 204 status code
94 RewriteRule ^api/v1/status$ - [R=204,L]
95
96 #push-to-my-ouya needs php scripting support
97 RewriteRule ^api/v1/queued_downloads?$ /api/v1/queued_downloads.php [END]
98
99 RewriteCond %{REQUEST_METHOD} DELETE
100 RewriteRule ^api/v1/queued_downloads/(.+)?$ /api/v1/queued_downloads_delete.php?game=$1 [END]