diff --git a/.htaccess b/.htaccess index 8e697fa..07d5b1a 100644 --- a/.htaccess +++ b/.htaccess @@ -17,8 +17,6 @@ RewriteCond %{REQUEST_URI} !^/admin/.*$ [NC] # Wyklucza ścieżki rozpoczynając RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [R=301,L] -ErrorDocument 404 /index.php - RewriteCond %{REQUEST_URI} !^(.*)/libraries/(.*) [NC] RewriteCond %{REQUEST_URI} !^(.*)/layout/(.*) [NC] RewriteRule ^admin/([^/]*)/([^/]*)/(.*)$ admin/index.php?module=$1&action=$2&$3 [L] @@ -462,4 +460,7 @@ RewriteRule ^co-warto-zabrac-jadac-na-urlop-z-dziecmi$ index.php?article=18&lang RewriteRule ^jaki-wybrac-gryzak-dla-niemowlaka$ index.php?article=19&lang=pl&%{QUERY_STRING} [L] RewriteRule ^prezent-dla-noworodka-oryginalne-prezenty-dla-niemowlat$ index.php?article=20&lang=pl&%{QUERY_STRING} [L] RewriteRule ^pielegnacja-noworodka-jak-prawidlowo-dbac-o-higiene-dziecka$ index.php?article=21&lang=pl&%{QUERY_STRING} [L] -RewriteRule ^smoczki-bibs-czy-warto-kupowac$ index.php?article=22&lang=pl&%{QUERY_STRING} [L] \ No newline at end of file +RewriteRule ^smoczki-bibs-czy-warto-kupowac$ index.php?article=22&lang=pl&%{QUERY_STRING} [L] +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^ index.php [L] \ No newline at end of file diff --git a/autoload/class.S.php b/autoload/class.S.php index 71e04c1..6d14e85 100644 --- a/autoload/class.S.php +++ b/autoload/class.S.php @@ -769,6 +769,11 @@ class S $htaccess_data ); } + $htaccess_data .= PHP_EOL; + $htaccess_data .= 'RewriteCond %{REQUEST_FILENAME} !-f' . PHP_EOL; + $htaccess_data .= 'RewriteCond %{REQUEST_FILENAME} !-d' . PHP_EOL; + $htaccess_data .= 'RewriteRule ^ index.php [L]'; + $fp = fopen( $dir . '.htaccess', 'w' ); fwrite( $fp, $htaccess_data ); fclose( $fp ); diff --git a/index.php b/index.php index 870a0ba..e0ef074 100644 --- a/index.php +++ b/index.php @@ -103,7 +103,7 @@ if ( $request_uri != '' ) $pattern = $route['pattern']; $destination = $route['destination']; - if ( preg_match("#^" . $pattern . "#", $request_uri, $matches ) ) + if ( preg_match( "#^" . $pattern . "#", $request_uri, $matches ) ) { // Replace placeholders in the destination with matches from the request URI $destination = preg_replace( "#^" . $pattern . "#", $destination, $request_uri ); diff --git a/libraries/htaccess.conf b/libraries/htaccess.conf index 6fbef84..ea0d799 100644 --- a/libraries/htaccess.conf +++ b/libraries/htaccess.conf @@ -3,9 +3,19 @@ RewriteBase / Options +FollowSymlinks Options -Indexes -{REDIRECT} +# Przekierowanie z www na bez www i z http na https w jednym kroku +RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] +RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L] -ErrorDocument 404 /404.html +# Przekierowanie z http na https, jeśli nie zawiera www +RewriteCond %{HTTPS} off +RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] + +# Usuwanie końcowego slash'a dla niekatalogów +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_URI} !^/admin/.*$ [NC] # Wyklucza ścieżki rozpoczynające się od "admin/" +RewriteCond %{REQUEST_URI} (.+)/$ +RewriteRule ^ %1 [R=301,L] RewriteCond %{REQUEST_URI} !^(.*)/libraries/(.*) [NC] RewriteCond %{REQUEST_URI} !^(.*)/layout/(.*) [NC] @@ -34,16 +44,27 @@ RewriteRule ^panel-klienta/edytuj-adres/([0-9]*)$ index.php?module=shop_client&a RewriteRule ^panel-klienta/usun-adres/([0-9]*)$ index.php?module=shop_client&action=address_delete&id=$1 [L] RewriteRule ^thumb/([0-9]*)/([0-9]*)/(.*)$ /libraries/thumb.php?img=$3&w=$1&h=$2 [L] +RewriteCond %{REQUEST_URI} ^/shopBasket/(.*)/(.*) [NC] +RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteCond %{REQUEST_URI} ^/shopClient/(.*)/(.*) [NC] +RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteCond %{REQUEST_URI} ^/shopProduct/(.*)/(.*) [NC] +RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteCond %{REQUEST_URI} ^/shopCoupon/(.*)/(.*) [NC] +RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteCond %{REQUEST_URI} ^/search/(.*)/(.*) [NC] +RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] + RewriteCond %{REQUEST_URI} ^/shopBasket/(.*) [NC] -RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteRule ^([^/]*)/([^/]*)$ index.php?module=$1&action=$2 [L] RewriteCond %{REQUEST_URI} ^/shopClient/(.*) [NC] -RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteRule ^([^/]*)/([^/]*)$ index.php?module=$1&action=$2 [L] RewriteCond %{REQUEST_URI} ^/shopProduct/(.*) [NC] -RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteRule ^([^/]*)/([^/]*)$ index.php?module=$1&action=$2 [L] RewriteCond %{REQUEST_URI} ^/shopCoupon/(.*) [NC] -RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteRule ^([^/]*)/([^/]*)$ index.php?module=$1&action=$2 [L] RewriteCond %{REQUEST_URI} ^/search/(.*) [NC] -RewriteRule ^([^/]*)/([^/]*)/(.*)$ index.php?module=$1&action=$2&$3 [L] +RewriteRule ^([^/]*)/([^/]*)$ index.php?module=$1&action=$2 [L] RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php RewriteRule ^ /%1 [R=301,L]