# =======================================================
# 1. DÉNES NEXTCLOUD JAVÍTÁSOK (ABSZOLÚT URL-ekkel)
# =======================================================
# Könyvtárlistázás tiltása (Biztonság)
Options -Indexes

<IfModule mod_rewrite.c>
    RewriteEngine on

    # BIZTONSÁGI KIVÉTEL: Az SSL megújítást (acme-challenge) NE bántsuk!
    RewriteRule ^\.well-known/acme-challenge/ - [L]

    # Nextcloud átirányítások TELJES URL-lel
    RewriteRule ^\.well-known/host-meta https://fdenes.hu/nextcloud/public.php?service=host-meta [QSA,L]
    RewriteRule ^\.well-known/host-meta\.json https://fdenes.hu/nextcloud/public.php?service=host-meta-json [QSA,L]
    RewriteRule ^\.well-known/webfinger https://fdenes.hu/nextcloud/index.php/.well-known/webfinger [R=301,L]
    RewriteRule ^\.well-known/nodeinfo https://fdenes.hu/nextcloud/index.php/.well-known/nodeinfo [R=301,L]
    RewriteRule ^\.well-known/carddav https://fdenes.hu/nextcloud/remote.php/dav/ [R=301,L]
    RewriteRule ^\.well-known/caldav https://fdenes.hu/nextcloud/remote.php/dav/ [R=301,L]
</IfModule>

# =======================================================
# 2. EREDETI WORDPRESS ÉS CACHE BEÁLLÍTÁSOK
# =======================================================

# BEGIN SpeedyCacheheaders
FileETag None
<IfModule mod_headers.c>
    Header unset ETag
</IfModule>

<FilesMatch "\.(html)$">
    <IfModule mod_headers.c>
        Header set x-speedycache-source "Server"
        Header set Cache-Tag "liv-pc.hu"
        Header set CDN-Cache-Control "max-age=1296000"
        Header set Cache-Control "public"
        Header unset Pragma
        Header unset Last-Modified
    </IfModule>
</FilesMatch>

<FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
    <IfModule mod_headers.c>
        Header unset Pragma
        Header set Cache-Control "public"
    </IfModule>
</FilesMatch>
# END SpeedyCacheheaders

# BEGIN Gzipspeedycache
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE font/opentype
    AddOutputFilterByType DEFLATE font/otf
    AddOutputFilterByType DEFLATE font/ttf
    AddOutputFilterByType DEFLATE font/woff
    AddOutputFilterByType DEFLATE font/woff2
    AddOutputFilterByType DEFLATE text/js
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    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/font-woff2
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>
# END Gzipspeedycache

# BEGIN LBCspeedycache
<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault A0
    ExpiresByType text/css A31536000
    ExpiresByType text/javascript A31536000
    ExpiresByType font/ttf A31536000
    ExpiresByType font/otf A31536000
    ExpiresByType font/woff A31536000
    ExpiresByType font/woff2 A31536000
    ExpiresByType image/jpg A31536000
    ExpiresByType image/jpeg A31536000
    ExpiresByType image/png A31536000
    ExpiresByType image/gif A31536000
    ExpiresByType image/webp A31536000
    ExpiresByType image/x-icon A31536000
    ExpiresByType image/svg+xml A31536000
    ExpiresByType image/vnd.microsoft.icon A31536000
    ExpiresByType video/ogg A31536000
    ExpiresByType video/mp4 A31536000
    ExpiresByType video/webm A31536000
    ExpiresByType audio/ogg A31536000
    ExpiresByType application/pdf A31536000
    ExpiresByType application/javascript A31536000
    ExpiresByType application/x-javascript A31536000
    ExpiresByType application/x-font-ttf A31536000
    ExpiresByType application/x-font-woff A31536000
    ExpiresByType application/font-woff A31536000
    ExpiresByType application/font-woff2 A31536000
    ExpiresByType application/vnd.ms-fontobject A31536000
</IfModule>
# END LBCspeedycache

# BEGIN WEBPspeedycache
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_ACCEPT} image/webp
    RewriteCond %{REQUEST_FILENAME} \.(jpe?g|png|gif)$
    RewriteCond %{DOCUMENT_ROOT}/$1.webp -f
    RewriteRule ^(.+)\.(jpe?g|png|gif)$ $1.webp [T=image/webp,L]
</IfModule>

<IfModule mod_headers.c>
    Header append Vary Accept env=REDIRECT_accept
</IfModule>

AddType image/webp .webp
# END WEBPspeedycache

# BEGIN speedycache
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_METHOD} GET
    RewriteCond %{HTTP_USER_AGENT} !(Mediatoolkitbot|facebookexternalhit|SpeedyCacheCCSS)
    RewriteCond %{QUERY_STRING} =""
    RewriteCond %{HTTP:Cookie} !(comment_author_|wordpress_logged_in_)

    RewriteCond %{REQUEST_URI} !(\/){2}$
    RewriteCond %{REQUEST_URI} !^/(wp-(?:admin|login|register|comments-post|cron|json))/ [NC]
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/speedycache/%{HTTP_HOST}/all%{REQUEST_URI}/index.html -f
    RewriteRule ^(.*) /wp-content/cache/speedycache/%{HTTP_HOST}/all%{REQUEST_URI}/index.html [L]
</IfModule>
# END speedycache

# BEGIN WordPress
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</IfModule>
# END WordPress

# BEGIN LiteSpeed
<IfModule Litespeed>
    SetEnv noabort 1
</IfModule>
# END LiteSpeed

# =======================================================
# 3. PHP BEÁLLÍTÁSOK (TUNING + OPCACHE)
# =======================================================
<IfModule php8_module>
    php_flag display_errors Off
    php_value max_execution_time 3600
    php_value max_input_time 3600
    php_value max_input_vars 3000
    php_value memory_limit 512M
    php_value post_max_size 1G
    php_value session.gc_maxlifetime 1440
    php_value upload_max_filesize 1G
    php_flag zlib.output_compression Off
    php_value output_buffering 0
    # OPcache aktiválása
    php_value opcache.enable 1
    php_value opcache.enable_cli 1
    php_value opcache.memory_consumption 128
    php_value opcache.interned_strings_buffer 16
    php_value opcache.max_accelerated_files 10000
    php_value opcache.revalidate_freq 1
    php_value opcache.save_comments 1
</IfModule>

<IfModule lsapi_module>
    php_flag display_errors Off
    php_value max_execution_time 3600
    php_value max_input_time 3600
    php_value max_input_vars 3000
    php_value memory_limit 512M
    php_value post_max_size 1G
    php_value session.gc_maxlifetime 1440
    php_value upload_max_filesize 1G
    php_flag zlib.output_compression Off
    php_value output_buffering 0
    # OPcache aktiválása
    php_value opcache.enable 1
    php_value opcache.enable_cli 1
    php_value opcache.memory_consumption 128
    php_value opcache.interned_strings_buffer 16
    php_value opcache.max_accelerated_files 10000
    php_value opcache.revalidate_freq 1
    php_value opcache.save_comments 1
</IfModule>