# <IfModule mod_rewrite.c>
#     <IfModule mod_negotiation.c>
#         Options -MultiViews -Indexes
#     </IfModule>

#     RewriteEngine On

#     # Handle Authorization Header
#     RewriteCond %{HTTP:Authorization} .
#     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

#     # Redirect Trailing Slashes If Not A Folder...
#     RewriteCond %{REQUEST_FILENAME} !-d
#     RewriteCond %{REQUEST_URI} (.+)/$
#     RewriteRule ^ %1 [L,R=301]

#     # Send Requests To Front Controller...
#     RewriteCond %{REQUEST_FILENAME} !-d
#     RewriteCond %{REQUEST_FILENAME} !-f
#     RewriteRule ^ index.php [L]



# # RewriteCond %{HTTP_HOST} ^www\.([^.]+\.ezbuild\.shop)$ [NC]
# # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [R=301,L]

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


# </IfModule>

# <IfModule mod_headers.c>
#     Header set Access-Control-Allow-Origin "*"
#     Header set Access-Control-Allow-Credentials true
# </IfModule>

# <IfModule mod_deflate.c>
#   AddOutputFilterByType DEFLATE application/javascript
#   AddOutputFilterByType DEFLATE application/rss+xml
#   AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
#   AddOutputFilterByType DEFLATE application/x-font
#   AddOutputFilterByType DEFLATE application/x-font-opentype
#   AddOutputFilterByType DEFLATE application/x-font-otf
#   AddOutputFilterByType DEFLATE application/x-font-truetype
#   AddOutputFilterByType DEFLATE application/x-font-ttf
#   AddOutputFilterByType DEFLATE application/x-javascript
#   AddOutputFilterByType DEFLATE application/xhtml+xml
#   AddOutputFilterByType DEFLATE application/xml
#   AddOutputFilterByType DEFLATE font/opentype
#   AddOutputFilterByType DEFLATE font/otf
#   AddOutputFilterByType DEFLATE font/ttf
#   AddOutputFilterByType DEFLATE image/svg+xml
#   AddOutputFilterByType DEFLATE image/x-icon
#   AddOutputFilterByType DEFLATE text/css
#   AddOutputFilterByType DEFLATE text/html
#   AddOutputFilterByType DEFLATE text/javascript
#   AddOutputFilterByType DEFLATE text/plain
# </IfModule>
# <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 mime ^image/.*
#   mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
# </IfModule>

# # Leverage Browser 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 text/css "access 1 month"
#   ExpiresByType text/html "access 1 month"
#   ExpiresByType application/pdf "access 1 month"
#   ExpiresByType text/x-javascript "access 1 month"
#   ExpiresByType application/x-shockwave-flash "access 1 month"
#   ExpiresByType image/x-icon "access 1 year"
#   ExpiresDefault "access 1 month"
# </IfModule>
# <IfModule mod_headers.c>
#   <filesmatch "\.(ico|flv|jpg|jpeg|png|gif|css|swf|svg)$">
#   Header set Cache-Control "max-age=31536000, public"
#   </filesmatch>
#   <filesmatch "\.(html|htm)$">
#   Header set Cache-Control "max-age=7200, private, must-revalidate"
#   </filesmatch>
#   <filesmatch "\.(pdf)$">
#   Header set Cache-Control "max-age=86400, public"
#   </filesmatch>
#   <filesmatch "\.(js)$">
#   Header set Cache-Control "max-age=2678400, private"
#   </filesmatch>
# </IfModule>

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # NEO editor-only files: the unpublished preview draft, its atomic-write
    # temp files, the neo.json save history and repair backups (neo.json.bak-*) are
    # read by PHP from disk only.
    # Never serve them over HTTP (an unpublished draft is not public content).
    # Live files (css/neo.json, compiled css, images) are not affected.
    RewriteRule ^shops/+[^/]+/+css/+(neo\.draft\.json|neo\.json\.tmp\.|neo\.json\.bak-|history(/|$)) - [F,NC,L]

    # Security (T-33): SMS campaign recipient lists (shops/{store}/campaign/{id}.json,
    # names + phone numbers, sequential ids). Written and read by PHP from disk only
    # (MailingController, StoreController@unsubscribe) - never served over HTTP.
    RewriteRule ^shops/+[^/]+/+campaign(/|$) - [F,NC,L]



    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]



# RewriteCond %{HTTP_HOST} ^www\.([^.]+\.ezbuild\.shop)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [R=301,L]

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


</IfModule>

<IfModule mod_headers.c>
    # The signed course-upload host owns its strict CORS policy in Laravel.
    # Keep the legacy wildcard behavior everywhere else without appending a
    # conflicting second origin header to upload responses.
    SetEnvIfExpr "%{HTTP_HOST} != 'upload.etx.co.il'" ezbuild_global_cors
    Header set Access-Control-Allow-Origin "*" env=ezbuild_global_cors
    Header set Access-Control-Allow-Credentials true env=ezbuild_global_cors
</IfModule>

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTPS} !=on  [NC]
    # RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    # RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
</IfModule>

<IfModule LiteSpeed>
  CacheLookup public on
</IfModule>

<IfModule litespeed>
    CacheLookup on
    RewriteEngine On
    RewriteRule .* - [E=cache-control:max-age=31536000]
</IfModule>
