RewriteEngine On
RewriteBase /
Options +FollowSymlinks
Options -Indexes

RewriteCond %{HTTP_USER_AGENT} Bytedance [NC]
RewriteRule .* - [F,L]

# Blokowanie Bytespider
RewriteCond %{HTTP_USER_AGENT} Bytespider [NC]
RewriteRule .* - [F,L]

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]

RewriteCond %{REQUEST_URI}  !^(.*)/libraries/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/temp/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/layout/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/resources/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/images/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/posters_images/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/upload/(.*) [NC]
RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [QSA,L]

RewriteRule ^logowanie$ index.php?module=users&action=login_form [L]
RewriteRule ^finances/tags.json$ index.php?module=finances&action=tags_json [L]