Refactor .htaccess file and update URL routing logic
This commit is contained in:
@@ -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]
|
||||
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]
|
||||
@@ -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 );
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user