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]
## Remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteCond %{REQUEST_URI} !^/admin/(.*) [NC]
RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [L,R=301]

ErrorDocument 404 /404.html

RewriteCond %{REQUEST_URI}  !^(.*)/libraries/(.*) [NC]
RewriteCond %{REQUEST_URI}  !^(.*)/css/(.*) [NC]
RewriteRule ^admin/([^/]*)/([^/]*)/(.*)$ admin/index.php?module=$1&action=$2&$3 [L]


RewriteRule ^admin/$ admin/index.php [L]
RewriteRule ^wyszukiwarka$ index.php?search=true&lang=pl [L]
RewriteRule ^wersja-tymczasowa$ index.php?devel=true&lang=pl [L]
RewriteRule ^pixieset/(.*)$ index.php?module=articles&action=image&hash=$1 [L]
RewriteRule ^pixieset-wszystkie/(.*)$ index.php?module=articles&action=images_download&hash=$1 [L]
RewriteRule ^audyt-seo/wynik$ index.php?module=auditSEO&action=main_view&%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} ^/auditSEO/(.*) [NC]
RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php
RewriteRule ^ /%1 [R=301,L]
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresByType text/x-component "access plus 1 year"
ExpiresByType text/html "access plus 0 seconds"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds"
ExpiresByType text/cache-manifest "access plus 0 seconds"
ExpiresByType audio/ogg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/ogg "access plus 1 year"
ExpiresByType video/webm "access plus 1 year"
ExpiresByType application/atom+xml "access plus 1 hour"
ExpiresByType application/rss+xml "access plus 1 hour"
ExpiresByType application/font-woff "access plus 1 year"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType font/opentype "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
<Files *.conf>
  Order Deny,Allow
  Deny from all
</Files>
<Files *.log>
  Order Deny,Allow
  Deny from all
</Files>
<Files *.ini>
  Order Deny,Allow
  Deny from all
</Files>
RewriteRule ^pl/$ index.php?a=change_language&id=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid|hash)=[^&]+(&.*)?
RewriteRule ^$ index.php?a=page&id=2&lang=pl&%{QUERY_STRING} [L]

RewriteCond %{REQUEST_URI} ^/home$
RewriteRule ^(.*)$ https://it.vidok.com/ [R=301,L]
RewriteCond %{REQUEST_URI} ^/home/s/1$
RewriteRule ^(.*)$ https://it.vidok.com/ [R=301,L]
RewriteCond %{REQUEST_URI} "^/$"
RewriteRule ^$ index.php?a=page&id=2&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^home(|/)$ index.php?a=page&id=2&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^home/s/1(|/)$ home [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^home/s/([0-9]+)(|/)$ index.php?a=page&id=2&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule home(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^home(|/)$ index.php?a=page&id=2&lang=pl [L]
RewriteRule ^home/s/([0-9]+)(|/)$ index.php?a=page&id=2&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^colori-pvc(|/)$ index.php?a=page&id=11&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^colori-pvc/s/1(|/)$ colori-pvc [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^colori-pvc/s/([0-9]+)(|/)$ index.php?a=page&id=11&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule colori-pvc(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^colori-pvc(|/)$ index.php?a=page&id=11&lang=pl [L]
RewriteRule ^colori-pvc/s/([0-9]+)(|/)$ index.php?a=page&id=11&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^finestre(|/)$ index.php?a=page&id=1&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^finestre/s/1(|/)$ finestre [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^finestre/s/([0-9]+)(|/)$ index.php?a=page&id=1&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule finestre(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^finestre(|/)$ index.php?a=page&id=1&lang=pl [L]
RewriteRule ^finestre/s/([0-9]+)(|/)$ index.php?a=page&id=1&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^colori-legno(|/)$ index.php?a=page&id=12&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^colori-legno/s/1(|/)$ colori-legno [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^colori-legno/s/([0-9]+)(|/)$ index.php?a=page&id=12&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule colori-legno(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^colori-legno(|/)$ index.php?a=page&id=12&lang=pl [L]
RewriteRule ^colori-legno/s/([0-9]+)(|/)$ index.php?a=page&id=12&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^legno(|/)$ index.php?a=page&id=8&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^legno/s/1(|/)$ legno [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^legno/s/([0-9]+)(|/)$ index.php?a=page&id=8&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule legno(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^legno(|/)$ index.php?a=page&id=8&lang=pl [L]
RewriteRule ^legno/s/([0-9]+)(|/)$ index.php?a=page&id=8&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^dettagli-pvc(|/)$ index.php?a=page&id=13&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^dettagli-pvc/s/1(|/)$ dettagli-pvc [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^dettagli-pvc/s/([0-9]+)(|/)$ index.php?a=page&id=13&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule dettagli-pvc(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^dettagli-pvc(|/)$ index.php?a=page&id=13&lang=pl [L]
RewriteRule ^dettagli-pvc/s/([0-9]+)(|/)$ index.php?a=page&id=13&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^pvc(|/)$ index.php?a=page&id=9&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^pvc/s/1(|/)$ pvc [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^pvc/s/([0-9]+)(|/)$ index.php?a=page&id=9&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule pvc(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^pvc(|/)$ index.php?a=page&id=9&lang=pl [L]
RewriteRule ^pvc/s/([0-9]+)(|/)$ index.php?a=page&id=9&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^dettagli-legno(|/)$ index.php?a=page&id=14&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^dettagli-legno/s/1(|/)$ dettagli-legno [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^dettagli-legno/s/([0-9]+)(|/)$ index.php?a=page&id=14&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule dettagli-legno(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^dettagli-legno(|/)$ index.php?a=page&id=14&lang=pl [L]
RewriteRule ^dettagli-legno/s/([0-9]+)(|/)$ index.php?a=page&id=14&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^legno-alluminio(|/)$ index.php?a=page&id=10&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^legno-alluminio/s/1(|/)$ legno-alluminio [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^legno-alluminio/s/([0-9]+)(|/)$ index.php?a=page&id=10&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule legno-alluminio(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^legno-alluminio(|/)$ index.php?a=page&id=10&lang=pl [L]
RewriteRule ^legno-alluminio/s/([0-9]+)(|/)$ index.php?a=page&id=10&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^porte(|/)$ index.php?a=page&id=3&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^porte/s/1(|/)$ porte [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^porte/s/([0-9]+)(|/)$ index.php?a=page&id=3&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule porte(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^porte(|/)$ index.php?a=page&id=3&lang=pl [L]
RewriteRule ^porte/s/([0-9]+)(|/)$ index.php?a=page&id=3&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^sistemi-scorrevoli(|/)$ index.php?a=page&id=4&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^sistemi-scorrevoli/s/1(|/)$ sistemi-scorrevoli [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^sistemi-scorrevoli/s/([0-9]+)(|/)$ index.php?a=page&id=4&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule sistemi-scorrevoli(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^sistemi-scorrevoli(|/)$ index.php?a=page&id=4&lang=pl [L]
RewriteRule ^sistemi-scorrevoli/s/([0-9]+)(|/)$ index.php?a=page&id=4&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^persiane(|/)$ index.php?a=page&id=5&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^persiane/s/1(|/)$ persiane [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^persiane/s/([0-9]+)(|/)$ index.php?a=page&id=5&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule persiane(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^persiane(|/)$ index.php?a=page&id=5&lang=pl [L]
RewriteRule ^persiane/s/([0-9]+)(|/)$ index.php?a=page&id=5&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^tapparelle(|/)$ index.php?a=page&id=6&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^tapparelle/s/1(|/)$ tapparelle [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^tapparelle/s/([0-9]+)(|/)$ index.php?a=page&id=6&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule tapparelle(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^tapparelle(|/)$ index.php?a=page&id=6&lang=pl [L]
RewriteRule ^tapparelle/s/([0-9]+)(|/)$ index.php?a=page&id=6&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^katalog(|/)$ index.php?a=page&id=15&lang=pl&%{QUERY_STRING} [L]
RewriteRule ^katalog/s/1(|/)$ katalog [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^katalog/s/([0-9]+)(|/)$ index.php?a=page&id=15&lang=pl&bs=$1&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule katalog(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^katalog(|/)$ index.php?a=page&id=15&lang=pl [L]
RewriteRule ^katalog/s/([0-9]+)(|/)$ index.php?a=page&id=15&lang=pl&bs=$1 [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-2-gamma-cromatica(|/)$ index.php?article=2&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-2-gamma-cromatica(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-2-gamma-cromatica(|/)$ index.php?article=2&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-3-finestre-finestre-pvc(|/)$ index.php?article=3&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-3-finestre-finestre-pvc(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-3-finestre-finestre-pvc(|/)$ index.php?article=3&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-4-finestre-finestre-legno(|/)$ index.php?article=4&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-4-finestre-finestre-legno(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-4-finestre-finestre-legno(|/)$ index.php?article=4&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-5-finestre-legno-alluminio(|/)$ index.php?article=5&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-5-finestre-legno-alluminio(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-5-finestre-legno-alluminio(|/)$ index.php?article=5&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-6-sistemi-scorrevoli(|/)$ index.php?article=6&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-6-sistemi-scorrevoli(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-6-sistemi-scorrevoli(|/)$ index.php?article=6&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^dettagli-pvc-1(|/)$ index.php?article=7&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^dettagli-pvc-1(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^dettagli-pvc-1(|/)$ index.php?article=7&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-8-dettagli-legno(|/)$ index.php?article=8&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-8-dettagli-legno(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-8-dettagli-legno(|/)$ index.php?article=8&lang=pl [L]

RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)(utm_source|gclid)=[^&]+(&.*)?
RewriteRule ^a-9-katalog(|/)$ index.php?article=9&lang=pl&%{QUERY_STRING} [L]
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^a-9-katalog(|/) %{REQUEST_URI}? [R=301,L]
RewriteRule ^a-9-katalog(|/)$ index.php?article=9&lang=pl [L]

RewriteRule ^oferty-pracy(|/)$ index.php?module=globelusAdverts&action=adverts_list&cp=1&%{QUERY_STRING} [L]
RewriteRule ^newsletter/signin$ index.php?module=newsletter&action=signin [L]
RewriteRule ^newsletter/confirm/hash=(.*)$ index.php?module=newsletter&action=confirm&hash=$1 [L]
RewriteRule ^newsletter/unsubscribe/hash=(.*)$ index.php?module=newsletter&action=unsubscribe&hash=$1 [L]
