RewriteEngine On
RewriteBase /
Options +FollowSymlinks
Options -Indexes

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=permanent]

# Statyczne zasoby - pomijaj
RewriteCond %{REQUEST_URI} ^/(libraries|layout|upload|temp)/ [NC]
RewriteRule ^ - [L]

# Istniejące pliki/katalogi - pomijaj
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Wszystko inne → index.php
RewriteRule ^(.*)$ index.php [L,QSA]
