Last active
December 23, 2015 11:39
-
-
Save renoirb/6629949 to your computer and use it in GitHub Desktop.
Reproduce a file from a github repo. (i.e. Poor man github pages!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#RewriteEngine On | |
#RewriteCond ^.*$ [L] | |
#RewriteRule ^(.*)$ /index.php?f=$1 | |
ErrorDocument 404 /index.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$base = 'https://raw.github.com/YOURUSERNAME/PROJECTNAME/master/FOLDERYOUWANT'; | |
$requestUri = $_SERVER['REQUEST_URI']; | |
$path = $base.(($requestUri == '/')?'/index.html':$requestUri); | |
$basenameArray = explode('.', basename($path)); | |
$file_handle = file_get_contents($path); | |
// Reproducing EVERY previous HTTP headers and relaying them from GitHub, except Server | |
foreach($http_response_header as $k => $v){ | |
if(strstr($v, 'Server') === false){ | |
header($v); | |
} | |
} | |
switch($basenameArray[1]){ | |
case 'js': | |
header('Content-Type: application/javascript'); | |
break; | |
case 'html': | |
header('Content-Type: text/html'); | |
break; | |
} | |
echo $file_handle; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment