# disable display of all other errors
SetEnv TZ America/Denver
#AddDefaultCharset utf-8
#php_flag default_charset "UTF-8"
php_flag short_open_tag On
php_value max_execution_time 480

RewriteEngine on

RewriteCond %{REQUEST_URI} ^/app/billing
RewriteRule ^(.*)$ http://%{HTTP_HOST} [L,R=301]

RewriteCond %{REQUEST_URI} ^/app/api
RewriteRule ^(.*)$ http://%{HTTP_HOST} [L,R=301]

RewriteCond %{REQUEST_URI} ^/app/sandbox
RewriteRule ^(.*)$ http://%{HTTP_HOST} [L,R=301]

RewriteCond %{REQUEST_URI} ^/app/capi
RewriteRule ^(.*)$ http://%{HTTP_HOST} [L,R=301]

RewriteCond %{REQUEST_URI} ^/app/scapi
RewriteRule ^(.*)$ http://%{HTTP_HOST} [L,R=301]

RewriteCond %{QUERY_STRING} ^token=(.*)
RewriteCond %{REQUEST_URI} ^/app/store/cart
# the ? at the end means redirect with no query_string
RewriteRule ^(.*)$ /app/index.php/store/cart/index/%1? [L]

# if valid hostname, get requested subdomain into local variable %2
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9._-][-a-z0-9._-]+)\.eoadev\.com(:80)?$ [NC]
# and if the requested subdomain is not "www"
RewriteCond %{HTTP_HOST} !^www\.eoadev\.com
# then set the subdomain variable
RewriteRule .* - [E=EOA_SUBDOMAIN:%2,NE]

# rewrite subdomains to the expression engine login
RewriteCond %{ENV:EOA_SUBDOMAIN} !=""
RewriteCond $1 !^(index\.php|images|robots\.txt|index\.html|index\.htm|css|fonts|scripts|tcpdf|uploads)
RewriteCond %{HTTP_HOST} ^([^.]+)
RewriteRule ^(.*)$ /app/index.php/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|index\.html|index\.htm|css|fonts|scripts|tcpdf|uploads)
RewriteRule ^(.*)$ /app/index.php/$1 [L]