Skip to content
View in the app

A better way to browse. Learn more.

Royal Hack

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[TUTO] Routeur PHP

Featured Replies

Bonjour,

Nativement les serveurs web redirige sur des pages php html ou autre avec des liens ayant comme forme : http://domain.tld/page.php

Le but est de remplacer la partie '/PAGE.PHP' par '/home

Architecture :

--pages
	page.php
	404.php
.htaccess
index.php
routeur.php

 

index.php

<?php 
header('Location: /home'); 
?>

Celui-ci renvoi inconditionnellement vers la page "/home"

routeur.php

<?php
$request_uri = explode('?', $_SERVER['REQUEST_URI'], 2);

switch ($request_uri[0]) {
//Page d'exemple
case '/home':
        require './pages/page.php';
        break;
// Cas inconnu -> 404
default:
        require './pages/404.php';
        break;
}

Nous séparons la variable "$_SERVER['REQUEST_URI']" afin d'en récupérer uniquement le "/XXXXX" "XXXXX" étant notre page recherché dans le cas présent "/home"

 

Notre routeur est fonctionnel, hors afin d'être pleinement opérationnel, il faut maintenant forcer à l'aide d'un ".htaccess" la redirection d'url vers notre routeur.php

.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ router.php [L,QSA]

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Important Information

Read Terms of Use to continue

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.