-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathroute.php
41 lines (29 loc) · 903 Bytes
/
route.php
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
27
28
29
30
31
32
33
34
35
36
37
38
<?php
// 处理URL中包含+号的情况
$_SERVER["PHP_SELF"] = str_replace(' ', '+', $_SERVER["PHP_SELF"] );
$path = $_SERVER['DOCUMENT_ROOT'] . $_SERVER["PHP_SELF"];
$uri = $_SERVER["REQUEST_URI"];
//print_r( $_SERVER );
$GLOBALS['lpconfig']['env'] = 'dev';
// 如果文件和目录存在,直接访问
if (file_exists($path))
{
$path2 = pathinfo($_SERVER["SCRIPT_FILENAME"]);
$header = false;
if( $path2['extension'] == 'ttf' ) $header = 'application/font-sfnt';
if( $path2['extension'] == 'eot' ) $header = 'application/vnd.ms-fontobject';
if( $path2['extension'] == 'woff' ) $header = 'application/font-woff';
if( $header )
{
header("Content-Type: ".$header);
readfile($_SERVER["SCRIPT_FILENAME"]);
}
else
return false;
}
else
{
putenv("REQUEST_URI=".$_SERVER["REQUEST_URI"]);
header("Access-Control-Allow-Origin: *");
require __DIR__ . '/index.php';
}