Skip to content

Instantly share code, notes, and snippets.

@tkw1536
Created March 11, 2014 20:46
Show Gist options
  • Save tkw1536/9494656 to your computer and use it in GitHub Desktop.
Save tkw1536/9494656 to your computer and use it in GitHub Desktop.
A really quick apache / php proxy script.
Options -Indexes
RewriteEngine on
# Add Slashes
RewriteCond %{REQUEST_URI} !(/$|\.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301,L]
# Force a domain - optional
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^example\.com [NC]
# RewriteRule (.*) http://example.com/$1 [R=301,L]
# Redirect to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_URL, "http://this_will_show_up.com/subfolder/" . $_SERVER["REQUEST_URI"]);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
foreach(explode("\n", $header) as $i){
header($i);
}
echo $body;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment