116 lines
4.1 KiB
PHP
116 lines
4.1 KiB
PHP
<?php
|
|
// Évite la boucle quand router.php inclut la page
|
|
if (defined('ROUTED_PRETTY')) {
|
|
return;
|
|
}
|
|
|
|
// Mapping vilain -> joli
|
|
$UGLY_TO_PRETTY = [
|
|
//racine
|
|
'/index.php' => '/',
|
|
'/detail_public.php' => '/specialistes',
|
|
'/connexion.php' => '/login',
|
|
'/choix_inscr.php' => '/choix-inscription',
|
|
'/inscription_client.php' => '/inscription-client',
|
|
'/inscription_praticien.php' => '/inscription-praticien',
|
|
'/mdp_oublie.php' => '/mot-de-passe-oublie',
|
|
'/avis_public.php' => '/avis',
|
|
//dossier client
|
|
'/public/client/informations.php' => '/profil',
|
|
'/public/client/modifier.php' => '/modifier-profil',
|
|
'/public/client/compte.php' => '/mon-compte',
|
|
'/public/client/list_praticien.php' => '/trouver-specialistes',
|
|
'/public/client/mes_favori.php' => '/mes-preferences',
|
|
'/public/client/detail_praticien.php' => '/specialiste',
|
|
'/public/client/avis.php' => '/donner-avis',
|
|
'/public/client/reserver_rdv.php' => '/reservation',
|
|
'/public/client/mes_rendez_vous.php' => '/mes-rendez-vous',
|
|
|
|
//Dossier praticien
|
|
'/public/praticien/informations.php' => '/profil-pro',
|
|
'/public/praticien/modifier.php' => '/modifier-profil-pro',
|
|
'/public/praticien/compte.php' => '/mon-compte-pro',
|
|
'/public/praticien/disponibilites.php' => '/mes-creneaux',
|
|
'/public/praticien/disponibilites_date.php' => '/mes-creneaux-date',
|
|
'/public/praticien/rendez_vous.php' => '/mes-consultations',
|
|
'/public/praticien/rendez_vous_du_jour.php' => '/consultations-du-jour',
|
|
'/public/praticien/agenda.php' => '/agenda',
|
|
'/public/praticien/synchronisation.php' => '/connecter-agenda',
|
|
'/public/praticien/resiliation.php' => '/abonnement',
|
|
'/public/praticien/factures.php' => '/mes-factures',
|
|
|
|
//Dossier messages
|
|
|
|
];
|
|
|
|
// Debug : ajouter ?_noredir=1 pour désactiver la redirection
|
|
if (! empty($_GET['_noredir'])) {
|
|
return;
|
|
}
|
|
|
|
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) ?? '/';
|
|
require_once __DIR__ . '/search_helpers.php';
|
|
|
|
// Redirection SEO pour result_search.php
|
|
if ($path === '/result_search.php' || $path === '/recherche') {
|
|
if (! empty($_GET['ajax'])) {
|
|
return;
|
|
}
|
|
|
|
$specialite = trim((string) ($_GET['specialite'] ?? ''));
|
|
$ville = trim((string) ($_GET['ville'] ?? ''));
|
|
|
|
if ($specialite !== '' || $ville !== '') {
|
|
$target = '/recherche';
|
|
|
|
$specSlug = '';
|
|
if ($specialite === '__OTHERS__') {
|
|
$specSlug = 'autres-specialistes';
|
|
} elseif ($specialite !== '') {
|
|
$specSlug = seo_spec_slug_from_input($specialite) ?? '';
|
|
}
|
|
|
|
if ($specSlug !== '') {
|
|
$target .= '/' . rawurlencode($specSlug);
|
|
}
|
|
|
|
$citySlug = '';
|
|
if ($ville !== '') {
|
|
$citySlug = seo_city_slug_from_input($ville);
|
|
}
|
|
|
|
if ($citySlug !== '') {
|
|
if ($specSlug === '') {
|
|
// si ville seule, on garde la query string pour éviter une structure bancale
|
|
$target = '/recherche/?' . http_build_query([
|
|
'specialite' => $specialite,
|
|
'ville' => $ville,
|
|
]);
|
|
header('Location: ' . $target, true, 301);
|
|
exit;
|
|
}
|
|
|
|
$target .= '/' . rawurlencode($citySlug);
|
|
}
|
|
|
|
$target .= '/';
|
|
|
|
$extra = $_GET;
|
|
unset($extra['specialite'], $extra['ville']);
|
|
|
|
if (! empty($extra)) {
|
|
$target .= '?' . http_build_query($extra);
|
|
}
|
|
|
|
header('Location: ' . $target, true, 301);
|
|
exit;
|
|
}
|
|
}
|
|
|
|
if (isset($UGLY_TO_PRETTY[$path])) {
|
|
$target = $UGLY_TO_PRETTY[$path];
|
|
$qs = $_SERVER['QUERY_STRING'] ? ('?' . $_SERVER['QUERY_STRING']) : '';
|
|
header('Location: ' . $target . $qs, true, 301);
|
|
exit;
|
|
}
|