# Redirect non-www to www

# Add a trailing slash (/) to a URL
rewrite ^([^.]*[^/])$ $1/ permanent;

# Specific redirections
rewrite ^/game,3\.html$ /game-3/? permanent;
rewrite ^/game,4\.html$ /game-4/? permanent;
rewrite ^/game,5\.html$ /game-5/? permanent;
rewrite ^/game,6\.html$ /game-6/? permanent;
rewrite ^/game,1439\.html$ /game-1439/? permanent;
rewrite ^/game,1440\.html$ /game-1440/? permanent;
rewrite ^/game,2\.html$ /game-2/? permanent;
rewrite ^/arcade,2-game\.html$ /arcade-2-game/? permanent;
rewrite ^/arcade,3-game\.html$ /arcade-3-game/? permanent;
rewrite ^/arcade,4-game\.html$ /arcade-4-game/? permanent;
rewrite ^/arcade,5-game\.html$ /arcade-5-game/? permanent;
rewrite ^/arcade,6-game\.html$ /arcade-6-game/? permanent;
rewrite ^/arcade,153-game\.html$ /arcade-153-game/? permanent;
rewrite ^/arcade,154-game\.html$ /arcade-154-game/? permanent;
rewrite ^/action,2-game\.html$ /action-2-game/? permanent;
rewrite ^/action,3-game\.html$ /action-3-game/? permanent;
rewrite ^/action,4-game\.html$ /action-4-game/? permanent;
rewrite ^/action,5-game\.html$ /action-5-game/? permanent;
rewrite ^/action,6-game\.html$ /action-6-game/? permanent;
rewrite ^/action,238-game\.html$ /action-238-game/? permanent;
rewrite ^/action,239-game\.html$ /action-239-game/? permanent;

# Create pretty URLs
rewrite ^/([^/]+)/$ /$1.html last;
rewrite ^/([^/]+)/([^/]+)/$ /$1/$2.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4/$5.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4/$5/$6.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4/$5/$6/$7.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4/$5/$6/$7/$8.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4/$5/$6/$7/$8/$9.html last;
rewrite ^/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/([^/]+)/$ /$1/$2/$3/$4/$5/$6/$7/$8/$9/$10.html last;
# End: Create pretty URLs

# Redirect all extensions to html
if ($is_args = ''){
	rewrite ^([^.]*)\.shtml$ $1.html permanent;
	rewrite ^([^.]*)\.phtml$ $1.html permanent;
	rewrite ^([^.]*)\.jhtml$ $1.html permanent;
	rewrite ^([^.]*)\.htm$ $1.html permanent;
	rewrite ^([^.]*)\.php$ $1.html permanent;
	rewrite ^([^.]*)\.aspx$ $1.html permanent;
	rewrite ^([^.]*)\.asp$ $1.html permanent;
	rewrite ^([^.]*)\.jsp$ $1.html permanent;
	rewrite ^([^.]*)\.apk$ $1.html permanent;
}
# End: Redirect all extensions to html
