Redirect from zen photo urls.
This commit is contained in:
parent
3e75aa451d
commit
b7641975a6
@ -1,4 +1,12 @@
|
||||
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
|
||||
<FilesMatch "(Makefile)|(.*\.pyc)">
|
||||
|
||||
<FilesMatch "Makefile">
|
||||
deny from all
|
||||
</FilesMatch>
|
||||
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
RewriteRule ^redirect\.php$ - [L]
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteRule . /redirect.php [L]
|
||||
|
31
web/redirect.php
Normal file
31
web/redirect.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
function cachePath($path) {
|
||||
if ($path[0] == '/')
|
||||
$path = substr($path, 1);
|
||||
if ($path[strlen($path) - 1] == '/')
|
||||
$path = substr($path, 0, strlen($path) - 1);
|
||||
$path = str_replace('_-_', '-', str_replace('/', '-', str_replace(' ', '_', str_replace('(', '', str_replace(')', '', str_replace('#', '', str_replace('[', '', str_replace(']', '', str_replace('"', '', str_replace("'", '', strtolower($path)))))))))));
|
||||
while (strpos($path, "--") !== false)
|
||||
$path = str_replace("--", "-", $path);
|
||||
while (strpos($path, "__") !== false)
|
||||
$path = str_replace("__", "_", $path);
|
||||
if (strlen(path) == 0)
|
||||
$path = "root";
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
$url = $_SERVER["SCRIPT_URL"];
|
||||
if ($url[strlen($url) - 1] == '/')
|
||||
$url = substr($url, 0, strlen($url) - 1);
|
||||
|
||||
if (strpos(strtolower($url), ".php") == strlen($url) - 4) {
|
||||
$url = substr($url, 0, strlen($url) - 4);
|
||||
$index = strrpos($url, "/");
|
||||
$redirect = "/#".cachePath(substr($url, 0, $index))."/".cachePath(substr($url, $index));
|
||||
} else
|
||||
$redirect = "/#".cachePath($url);
|
||||
|
||||
header("Location: $redirect");
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user