RewriteEngine on

#Make subfolders use these rules too if htaccess present----------
RewriteOptions InheritDown

#Manage directory listing
Options -Indexes

#Forbid access to resources folder
#RewriteRule ^resources/?$ - [F,L]


#Serve all pages over https except notes & radio---------------
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTP:CF-Visitor} !https
#RewriteCond %{HTTP_USER_AGENT} !BlackBerry [NC]
RewriteCond %{REQUEST_URI} !^/notes/
RewriteCond %{REQUEST_URI} !^/radio/
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]


#Remove html extensions from url--------------------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]


#Remove i=1 parameter from url----------------------------------
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]


#Error handling-------------------------------------------------
ErrorDocument 400 /resources/error.html
ErrorDocument 401 /resources/error.html
ErrorDocument 403 /resources/error.html
ErrorDocument 404 /resources/error.html
ErrorDocument 500 /resources/error.html


#Redirect pages-------------------------------------------------
#Redirect 301 /radio /radio/index.html
#Redirect 301 /table /table-generator.html
