AddType text/x-component .htc
Options +FollowSymLinks -indexes
RewriteEngine On

RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

# Strip leading "www." for any host that ends with ".mtcdevserver1-999.com" (handles any subdomain chain)
# this is required due to SSL being on a wildcard *.domain so it is causing a cors issue
RewriteCond %{HTTP_HOST} ^www\.(.+\.mtcdevserver(?:[1-9][0-9]{0,2})\.com)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

# Force www throughout site.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^static\. [NC]
RewriteCond %{HTTP_HOST} !\.mtcdevserver([1-9][0-9]{0,2})\.com$ [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Force HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# http redirect to main website

#RewriteCond %{HTTP_HOST} !^.*\.mtcserver22\.com [NC]
#RewriteCond %{HTTP_HOST} !^.*\.mtcdevserver6\.com [NC]
#RewriteRule ^(.*)$ https://www.pharmacydemo.mtcserver22.com/$1 [L,R=301]



Redirect 301 /robots.txt/ /robots.txt
Redirect 301 /sitemap.xml/ /sitemap.xml

RedirectMatch 301 ^/online-doctor(/)?$ /conditions/

RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]


# Fake image generator, great for quickly populating dummy images programmatically
RewriteRule fake_image(_([a-z]{1,20}))?(_([0-9]{1,2}))?\.png$ /core/images/image_faker.php?category=$2&picture_no=$4 [L]

RewriteRule ^newsletter(/)?$ /plugins/NewsletterSignup/ [QSA,L]

# Messaging
RewriteRule ^admin/messaging/?(.*) /plugins/MembersMessaging/admin/index.php?act=$1 [QSA,L]

# Judopay
RewriteRule ^shop\/checkout\/judopay\/?(.*)\/$ /plugins/Judopay/checkout/$1.php [QSA,L]

# RyftPay
RewriteRule ^shop/checkout/ryftpay/?(.*) /plugins/RyftPay/checkout/$1.php [QSA,L]

# Folder redirects
RewriteRule ^admin/?(.*) /core/admin/$1 [QSA,L]
RewriteRule ^css/?(.*) /core/css/$1 [QSA,L]
RewriteRule ^generator/?(.*) /core/generator/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f

# Home
RewriteRule ^home(/)$ / [R=301,L]

# Browse Page
RewriteRule ^shop/$ /pharmacy/ [R=301,QSA,L]
RewriteRule ^shop/browse/$ /pharmacy/ [R=301,QSA,L]
RewriteRule ^browse/$ /pharmacy/ [R=301,QSA,L]
RewriteRule ^browse$ /pharmacy/ [R=301,QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^browse/ajax.php(.*) /shop/browse/ajax.php [QSA]
RewriteRule ^pharmacy(.*) /shop/browse/index.php [QSA]

# Item page
RewriteRule ^item/([0-9]+)(/([_\&\'\,\+A-Za-z0-9-]+))?/([_\&\'\,\+A-Za-z0-9-]+).html$ shop/item.php?id=$1 [QSA]
RewriteRule ^medications/([a-zA-Z0-9\-]+)/?$ /shop/item.php?slug=$1 [QSA,L]

RewriteRule ^private_prescriptions(/)?(.*) /plugins/Prescriptions/$2 [QSA,L,NC]
RewriteRule ^members(/)?(.*) /modules/Members/$2 [QSA,L]

RewriteRule ^sitemap.xml /index.php [QSA,L]

# Categories landing
#RewriteRule ^online-doctor/([a-zA-Z\-]+)/([a-zA-Z0-9\-]+)(/?)$ /shop/item.php?slug=$2 [QSA,L]
#RewriteRule ^online-doctor/(.+)$ /shop/category.php?slug=$1 [QSA,L]

# CMS Rules
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(((([0-9a-z\-\\/]*)\/)|())([0-9a-z\-]+)\/?)$ /index.php [QSA,L,NC,E=FULLCMS_SLUG_URI:root/$1,E=FULLCMS_PAGE:$6]

# Error Handling
# Because core is multi-site system - one 404.html won't do the trick
# cms router shall handle and pull in the correct 404.html (still static)
ErrorDocument 404 /e404
ErrorDocument 403 /e404
# If the system has only one site you can use the cms auto generated 404.html
# which is located (depending on your site name) "/sites/www/404.html"
# ErrorDocument 404 /sites/www/404.html
# ErrorDocument 403 /sites/www/404.html

#debug-bar setting
RewriteRule ^debugbar/(.*) /vendor/maximebf/debugbar/src/DebugBar/Resources/$1 [L]

#don't give access unless its for debugbar and on devserver
RewriteCond %{HTTP_HOST} !^.*\.mtcdevserver4\.com [NC]
RewriteCond %{REQUEST_URI} !^.*debugbar.*$
RewriteRule ^vendor - [F]
RewriteRule ^.env - [F]
RewriteRule ^storage/* - [F]
RewriteRule ^database/* - [F]

# Hide Configuration
RewriteRule ^src - [F]
RewriteRule ^composer\.json - [F]
RewriteRule ^composer\.lock - [F]
RewriteRule ^\.gitignore - [F]
RewriteRule ^phpunit\.xml - [F]
RewriteRule ^README\.md - [F]
RewriteRule ^gulpfile\.js - [F]
RewriteRule ^package\.json - [F]
RewriteRule ^TODO\.rm - [F]

AddType application/font-woff woff
AddType application/font-woff2 woff2
AddType image/svg+xml .svg
AddType video/mp4 .mp4 .m4v

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/svg+xml "access 1 year"
ExpiresByType image/webp "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType text/css "access 6 month"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType text/javascript "access 6 month"
ExpiresByType text/x-javascript "access 6 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 6 month"
ExpiresByType application/x-javascript "access 6 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-woff "access 1 year"
ExpiresByType application/font-woff "access 1 year"
ExpiresByType application/font-woff2 "access 1 year"
ExpiresByType font/woff "access 1 year"
ExpiresByType video/mp4 "access plus 1 month"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

# Compress these file types on server before sending to client
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/jpg
AddOutputFilterByType DEFLATE image/jpeg
AddOutputFilterByType DEFLATE image/gif
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/webp

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

# Image Redirects for staging.

# If image does not exist on staging, fetch from live
# RewriteCond %{HTTP_HOST} !amplifiedclothing\.com [OR]
# RewriteCond %{HTTP_HOST} gld\.mtcdevserver\.com
# RewriteCond %{REQUEST_URI} \.(jpg|jpeg|gif|png)$ [NC]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule (.*)$ https://www.amplifiedclothing.com/$1 [L]

# Image Redirects for forks.


# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php5_module>
   php_flag asp_tags Off
   php_flag display_errors Off
   php_value max_execution_time 600
   php_value max_input_time 60
   php_value max_input_vars 50000
   php_value memory_limit 256M
   php_value session.gc_maxlifetime 36000
   php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
   php_value upload_max_filesize 100M
</IfModule>
# END cPanel-generated php ini directives, do not edit

<Files "makefile">
    Order allow,deny
    Deny from all
</Files>
