RewriteEngine on

<IfModule mod_headers.c>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|css|js|svg)$">
		Header add Access-Control-Allow-Origin "*"
		Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
		Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
	</FilesMatch>
	# Only if need hack CORS policy: No 'Access-Control-Allow-Origin'
	# Header add Access-Control-Allow-Origin "*"
</IfModule>

# For HTTPS
RewriteCond %{HTTP_HOST} !localhost
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Make sure using www as subdomain
RewriteCond %{HTTP_HOST} !localhost
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]

# SAAS
# Make sure to put following coding on root of public_html
# If not, separate it from this file and put into public_html's htaccess
# RewriteCond %{HTTP_HOST} !^dropbox.localhost$ [NC]
# RewriteRule ^(.*)$ http://dropbox.localhost/$1 [L,R=301]

# Ommitting index.php on CI
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|forum|asset|upload|thumb|tinydb|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]