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

# Specific redirections
if($is_args = ''){ rewrite ^/index\.php$ /index_php/? permanent; }
rewrite ^/index\.php/about-mickies-pub-kelowna$ /index_php/about-mickies-pub-kelowna/? permanent;
rewrite ^/index\.php/component/users$ /index_php/component/users/? permanent;
if ($args ~* ^view=registration$){ rewrite ^/index\.php/component/users/?$ /index_php/component/users/view-registration/? permanent; }
if ($args ~* ^view=remind$){ rewrite ^/index\.php/component/users/?$ /index_php/component/users/view-remind/? permanent; }
if ($args ~* ^view=reset$){ rewrite ^/index\.php/component/users/?$ /index_php/component/users/view-reset/? permanent; }
rewrite ^/index\.php/contact-mickies-pub$ /index_php/contact-mickies-pub/? permanent;
rewrite ^/index\.php/covid-19-safety-plan$ /index_php/covid-19-safety-plan/? permanent;
rewrite ^/index\.php/mickies-pub-news-and-events$ /index_php/mickies-pub-news-and-events/? permanent;
rewrite ^/index\.php/our-menus-mickies-pub-kelowna$ /index_php/our-menus-mickies-pub-kelowna/? permanent;
rewrite ^/index\.php/win-prizes-at-mickies-pub$ /index_php/win-prizes-at-mickies-pub/? permanent;
rewrite ^/index\.php/win-prizes-at-mickies-pub/pickem-rules$ /index_php/win-prizes-at-mickies-pub/pickem-rules/? permanent;
if ($args ~* ^option=com_breezingforms&Itemid=435&ff_form=1&ff_applic=mod_facileforms&ff_module_id=120&format=html&tmpl=component&ff_frame=1$){ rewrite ^/index\.php$ /index_option-com_breezingforms-Itemid-435-ff_form-1-ff_applic-mod_facileforms-ff_module_id-120-format-html-tmpl-component-ff_frame-1/? permanent; }
if ($args ~* ^option=com_breezingforms&Itemid=668&ff_form=1&ff_applic=mod_facileforms&ff_module_id=120&format=html&tmpl=component&ff_frame=1$){ rewrite ^/index\.php$ /index_option-com_breezingforms-Itemid-668-ff_form-1-ff_applic-mod_facileforms-ff_module_id-120-format-html-tmpl-component-ff_frame-1/? permanent; }
if ($args ~* ^option=com_breezingforms&Itemid=803&ff_form=1&ff_applic=mod_facileforms&ff_module_id=120&format=html&tmpl=component&ff_frame=1$){ rewrite ^/index\.php$ /index_option-com_breezingforms-Itemid-803-ff_form-1-ff_applic-mod_facileforms-ff_module_id-120-format-html-tmpl-component-ff_frame-1/? permanent; }
if ($args ~* ^option=com_content&view=article&id=52&Itemid=803$){ rewrite ^/index\.php$ /index_option-com_content-view-article-id-52-Itemid-803/? permanent; }
if ($args ~* ^option=com_content&view=article&id=84&Itemid=803$){ rewrite ^/index\.php$ /index_option-com_content-view-article-id-84-Itemid-803/? 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
