-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
69 lines (57 loc) · 2.36 KB
/
Copy pathserver.php
File metadata and controls
69 lines (57 loc) · 2.36 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// Get the current host and remove www. prefix
$host = $_SERVER['HTTP_HOST'] ?? '';
$host = preg_replace('/^www\./', '', $host);
// Remove trailing dots (fixes the dot folder issue)
$host = rtrim($host, '.');
// Remove port number
$host = preg_replace('/:\d+$/', '', $host);
// Get port information
$port = $_SERVER['SERVER_PORT'] ?? '8000';
// Eklenen kod: /storage/ URL'lerini domain bazlı dizine yönlendirme
if (strpos($uri, '/storage/') === 0) {
// Eğer localhost ise eski mantığı kullan
if (strpos($host, 'localhost') === 0) {
$storagePath = __DIR__ . '/storage/app/public' . str_replace('/storage', '', $uri);
} else {
// Domain bazlı storage path oluştur
$storagePath = __DIR__ . '/storage/multi/' . $host . '/public' . str_replace('/storage', '', $uri);
// Eğer domain'e özel dosya yoksa, eski storage'ı dene
if (!file_exists($storagePath)) {
$oldPath = __DIR__ . '/storage/app/public' . str_replace('/storage', '', $uri);
error_log(":{$port} [storage] File not found in domain storage, trying old path: " . $oldPath);
$storagePath = $oldPath;
}
}
// Debug log with port information
error_log(":{$port} [storage] Requested URI: " . $uri);
error_log(":{$port} [storage] Host: " . $host);
error_log(":{$port} [storage] Looking for file at: " . $storagePath);
if (file_exists($storagePath)) {
error_log(":{$port} [storage] File found at: " . $storagePath);
header('Content-Type: ' . mime_content_type($storagePath));
header('Cache-Control: public, max-age=31536000'); // 1 yıl cache
readfile($storagePath);
exit;
} else {
error_log(":{$port} [storage] File not found at any location");
header("HTTP/1.0 404 Not Found");
exit;
}
}
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
return false;
}
require_once __DIR__ . '/public/index.php';