# Settings
RewriteEngine on
RewriteBase /
# Prepend the www. if not present
RewriteCond %{HTTP_HOST} !^www.yarrt.com$ [NC]
RewriteRule ^(.*)$ http://www.yarrt.com/$1 [L,R=301]
# Redirect old backlinks
RewriteRule ^game.php?game=(.*)$ game/$1/ [L,R=301]
RewriteRule ^video.php?video=(.*)$ video/$1/ [L,R=301]
RewriteRule ^(games|videos).php?p=([0-9]+)&order=(file|views)$ $1/start-$2/sort-$3/ [L,R=301]
RewriteRule ^(games|videos).php$ $1/start-0/sort-file/ [L,R=301]
# URLs in the format of: (games|videos)/[p]/[order](/|)
RewriteRule ^(games|videos)/start-([0-9]+)/sort-(file|views)(/|)$ list.php?type=$1&p=$2&order=$3 [L]
# URLs in the format of: (game|video)/[name](/|)
RewriteRule ^(game|video)/(.*)/$ play.php?mode=$1&item=$2 [L]
RewriteRule ^(game|video)/(.*)$ play.php?mode=$1&item=$2 [L]
# URLs in the format of: fullscreen/(game|video)/[name](/|)
RewriteRule ^fullscreen/(game|video)/(.*)/$ fullscreen.php?type=$1&item=$2 [L]
RewriteRule ^fullscreen/(game|video)/(.*)$ fullscreen.php?type=$1&item=$2 [L]
# Redirect errors
ErrorDocument 404 /error.php?e=404
ErrorDocument 500 /error.php?e=500