Skip to content

Instantly share code, notes, and snippets.

@AD7six
Created October 16, 2010 18:48
Show Gist options
  • Save AD7six/630149 to your computer and use it in GitHub Desktop.
Save AD7six/630149 to your computer and use it in GitHub Desktop.
A simple means of generating a local mirror of another website as you use it.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
<?php
$domain = 'http://php.net';
$uri = $_SERVER['REQUEST_URI'];
if ($pos = $strpos($uri, '?')) {
$uri = substr($uri, 0, $pos);
}
$dir = dirname($uri);
exec('mkdir -p .' . $dir);
exec("cd .$dir && wget {$domain}$uri");
echo file_get_contents('.' . $uri);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment