source: spip-zone/_plugins_/hash_documents/action/hash_404.php @ 48997

Last change on this file since 48997 was 48997, checked in by yffic@…, 10 years ago
  • Faire fonctionner le .htaccess dans le cadre d'un spip mutualisé ou d'un spip dans un sous domaine
  • Mise en place des chaines de langue
File size: 1.5 KB
RevLine 
[48997]1<?php
2
3## fichier appele par le .htaccess de IMG/ ; lequel doit contenir :
4
5/*
6
7RewriteEngine On
8RewriteCond %{REQUEST_FILENAME} !-f
9# Si spip est range a la racine du domaine ou pour un mutualise
10RewriteRule .* /ecrire/?action=hash_404 [L]
11# Si spip est range dans un sous dossier spip
12#RewriteRule .* /spip/ecrire/?action=hash_404 [L]
13
14*/
15
16include_spip("hash_fonctions");
17$doc = preg_replace(',^.*?IMG/,', '', $_SERVER['REQUEST_URI']);
18
19if (($dest = hasher_adresser_document($doc)
20AND file_exists('../'.$GLOBALS['meta']['dir_img'].$dest))
21OR ($dest1 = hasher_adresser_document($doc, true)
22AND file_exists('../'.$GLOBALS['meta']['dir_img'].$dest))
23) {
24        $url = 'http://'.$_SERVER['HTTP_HOST'].preg_replace(',^(.*?IMG/).*,', '\1', $_SERVER['REQUEST_URI']).$dest;
25        header('HTTP/1.1 301 Moved Permanently');
26        header('Location: '.$url);
27        echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
28<html><head>
29<title>301 Moved Permanently</title>
30</head><body>
31<h1>Moved Permanently</h1>
32<p>The requested URL '.htmlspecialchars($_SERVER['REQUEST_URI']).' has moved to <a href="'.$url.'">'.$url.'</a>.</p>
33<hr>
34'.$_SERVER['SERVER_SIGNATURE'].'
35</body></html>
36';
37}
38else {
39        echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
40<html><head>
41<title>404 Not Found</title>
42</head><body>
43<h1>Not Found</h1>
44<p>The requested URL '.htmlspecialchars($_SERVER['REQUEST_URI']).' was not found on this server.</p>
45<hr>
46'.$_SERVER['SERVER_SIGNATURE'].'
47</body></html>
48';
49}
50
51?>
Note: See TracBrowser for help on using the repository browser.