$adr = $_SERVER['REQUEST_URI']; // wykrycie i usunięcie /12345 na końcu adresu $extract_number_pattern = "/\/\\d+/"; $matches = []; /* preg_match_all($extract_number_pattern, $adr, $matches); if(isset($matches[0][0])) $adr = str_replace($matches[0][0], '', $adr); */ if(preg_match('/\/pl\/oferta/', $adr)){ $adr2 = str_replace('/pl/oferta', '', $adr); $adr2 = str_replace('.', '-', $adr2); // header("HTTP/1.1 301 Moved Permanently"); preg_match_all($extract_number_pattern, $adr2, $matches); if(isset($matches[0][0])) $adr2 = str_replace($matches[0][0], '', $adr2); if(substr($adr2, -1) == '-' || substr($adr2, -1) == '.') $adr2 = substr($adr2, 0, -1); header("Location: $adr2", true, 301); die(); } if(preg_match('/\/oferta/', $adr)){ $adr1 = str_replace('/oferta', '', $adr); $adr1 = str_replace('.', '-', $adr1); preg_match_all($extract_number_pattern, $adr1, $matches); if(isset($matches[0][0])) $adr1 = str_replace($matches[0][0], '', $adr1); if(substr($adr1, -1) == '-' || substr($adr1, -1) == '.') $adr1 = substr($adr1, 0, -1); header("Location: $adr1", true, 301); die(); } if(preg_match('/\/pl\/c/', $adr)){ $adr3 = str_replace('/pl/c', '', $adr); $adr3 = str_replace('.', '-', $adr3); preg_match_all($extract_number_pattern, $adr3, $matches); if(isset($matches[0][0])) $adr3 = str_replace($matches[0][0], '', $adr3); if(substr($adr3, -1) == '-' || substr($adr3, -1) == '.') $adr3 = substr($adr3, 0, -1); header("Location: $adr3", true, 301); die(); } if(preg_match('/\./', $adr) && !preg_match('/\.php/', $adr) && !preg_match('/\.js/', $adr) && !preg_match('/\.css/', $adr) && !preg_match('/\.jpg/', $adr) && !preg_match('/\.webp/', $adr) && !preg_match('/\.png/', $adr) && !preg_match('/\.ico/', $adr) && !preg_match('/\.xml/', $adr) && !preg_match('/\.pdf/', $adr) && !preg_match('/admin/', $adr)){ $adr1 = str_replace('.', '-', $adr); if(substr($adr1, -1) == '-' || substr($adr1, -1) == '.') $adr1 = substr($adr1, 0, -1); header("Location: $adr1", true, 301); die(); } if(substr($adr, -1) == '-' || substr($adr, -1) == '.'){ $adr = substr($adr, 0, -1); header("Location: $adr", true, 301); die(); } /** * Main Bootstrap file * * DO NOT MODIFY THIS FILE! * * @author Adrian Slowik * @package Shoper */ // manage errors ini_set( 'display_errors', 'off' ); if(version_compare(PHP_VERSION, '5.4.0', '<')) { error_reporting( E_ALL ^ (E_NOTICE | E_USER_NOTICE) ); }else{ error_reporting( E_ALL ^ (E_NOTICE | E_USER_NOTICE | E_STRICT) ); } define( 'PATH_ROOT', dirname( __FILE__ ) ); define( 'BASE_URL', '/'); define( 'PHP_TAB', "\t"); $include_paths = explode(PATH_SEPARATOR, get_include_path()); $open_basedir = ini_get('open_basedir'); if(!empty($open_basedir)){ $open_basedir_paths = explode(PATH_SEPARATOR, $open_basedir); $included_paths = array(); foreach($include_paths as $path){ $path = realpath($path); foreach($open_basedir_paths as $restricted){ if(strpos($path, $restricted) === 0){ $included_paths[] = $path; break; } } } }else{ $included_paths = $include_paths; } set_include_path( realpath(PATH_ROOT . '/application/core/') . PATH_SEPARATOR . realpath(PATH_ROOT . '/application/models/') . PATH_SEPARATOR . realpath(PATH_ROOT) . PATH_SEPARATOR . realpath(PATH_ROOT . '/libraries/') . PATH_SEPARATOR . implode(PATH_SEPARATOR, $included_paths) ); ob_start(); // zacznij buforowanie odpowiedzi require "InitBoot.php"; // uruchom aplikację $content = ob_get_contents(); // zapisz, co aplikacja zwróciła ob_end_clean(); // wyczyść bufor // Sprawdź, czy aplikacja ustawiła kod błędu 404 if (http_response_code() === 404 || empty($content)) { header("Location: /", true, 302); exit; } // Jeśli nie 404 — wypisz stronę normalnie echo $content; ?>