-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.php
More file actions
26 lines (21 loc) · 762 Bytes
/
Copy pathrouter.php
File metadata and controls
26 lines (21 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
$matches = [];
if ( in_array($_SERVER["REQUEST_URI"],['/index.html', '/', ''])) {
echo file_get_contents('index.html');
die;
}
//Cuando en la peticion url tenemos un get con un elemento particulas
if(preg_match('/\/([^\/]+)\/([^\/]+)/', $_SERVER["REQUEST_URI"], $matches)){
$_GET['resource_type'] = $matches[1];
$_GET['resource_id'] = $matches[2];
require 'server.php';
//Cuando en la peticion url solo queremos ver todos los elementos
} elseif (preg_match('/\/([^\/]+)\/?/', $_SERVER["REQUEST_URI"], $matches)){
$_GET['resource_type'] = $matches[1];
error_log(print_r($matches, 1));
require 'server.php';
//No tenemos en la peticion un dato valido
}else{
error_log('No matches');
http_response_code(404);
}