docker-selfoss/run.php

36 lines
1.0 KiB
PHP
Raw Normal View History

2016-06-28 15:12:25 +00:00
<?php
// Only run this if running from php 5.4 embedded server
if (php_sapi_name() == 'cli-server') {
if ( preg_match( '/\.(?:js|ico|gif|jpg|png|css|asc|txt|eot|woff|ttf|ttf|svg)$/', $_SERVER["REQUEST_URI"] ) ) {
// serves fronted
if ( preg_match( '/^\/public/', $_SERVER["REQUEST_URI"] ) ) {
return false;
}
// serves favicons
if ( preg_match( '/^\/data/', $_SERVER["REQUEST_URI"] ) ) {
return false;
}
//redirects to proper location for favicons
if ( preg_match( '/(favicons|thumbnails)/', $_SERVER["REQUEST_URI"] ) ) {
header( "Location: /data".$_SERVER["REQUEST_URI"] );
exit;
}
//redirects to proper location for frontend
header( "Location: /public".$_SERVER["REQUEST_URI"] );
exit;
} else {
// taken from cli arg, hack for updater
$_SERVER["SERVER_ADDR"] = '127.0.0.1';
$_SERVER["SERVER_NAME"] = '127.0.0.1';
require("index.php");
}
}