Line | |
---|
1 | <?php |
---|
2 | |
---|
3 | ## fichier appele par le .htaccess de IMG/ ; lequel doit contenir : |
---|
4 | |
---|
5 | /* |
---|
6 | |
---|
7 | RewriteEngine On |
---|
8 | RewriteCond %{REQUEST_FILENAME} !-f |
---|
9 | RewriteRule .* /plugins/hash_documents/hash_404.php [L] |
---|
10 | |
---|
11 | */ |
---|
12 | |
---|
13 | |
---|
14 | @require 'hash_fonctions.php'; |
---|
15 | |
---|
16 | $doc = preg_replace(',^.*?IMG/,', '', $_SERVER['REQUEST_URI']); |
---|
17 | if (($dest = hasher_adresser_document($doc) |
---|
18 | AND file_exists('../../IMG/'.$dest)) |
---|
19 | OR ($dest = hasher_adresser_document($doc, true) |
---|
20 | AND file_exists('../../IMG/'.$dest)) |
---|
21 | ) { |
---|
22 | $url = 'http://'.$_SERVER['HTTP_HOST'].preg_replace(',^(.*?IMG/).*,', '\1', $_SERVER['REQUEST_URI']).$dest; |
---|
23 | header('HTTP/1.1 301 Moved Permanently'); |
---|
24 | header('Location: '.$url); |
---|
25 | echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
---|
26 | <html><head> |
---|
27 | <title>301 Moved Permanently</title> |
---|
28 | </head><body> |
---|
29 | <h1>Moved Permanently</h1> |
---|
30 | <p>The requested URL '.htmlspecialchars($_SERVER['REQUEST_URI']).' has moved to <a href="'.$url.'">'.$url.'</a>.</p> |
---|
31 | <hr> |
---|
32 | '.$_SERVER['SERVER_SIGNATURE'].' |
---|
33 | </body></html> |
---|
34 | '; |
---|
35 | } |
---|
36 | else { |
---|
37 | echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
---|
38 | <html><head> |
---|
39 | <title>404 Not Found</title> |
---|
40 | </head><body> |
---|
41 | <h1>Not Found</h1> |
---|
42 | <p>The requested URL '.htmlspecialchars($_SERVER['REQUEST_URI']).' was not found on this server.</p> |
---|
43 | <hr> |
---|
44 | '.$_SERVER['SERVER_SIGNATURE'].' |
---|
45 | </body></html> |
---|
46 | '; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
Note: See
TracBrowser
for help on using the repository browser.