<?php

/**
 * File: public/fallback.php.
 *
 * This file can be used to redirect non-existent files on your local environment
 * to the live environment. Be sure to assign the correct URL to the LIVE_URL constant.
 * This file should be in the web root.
 *
 *
 * Find the latest version here: https://bitbucket.org/pn-wordpress/workspace/snippets/Xkd5M8
 *
 *
 * NGINX configuration:
 *
 * Add the following rules to your nginx.conf below the '/' location block.
 *
 *
 *       	location ~* .(png|jpg|jpeg|svg|webp|gif|ico|mp3|mp4|mov|tif|tiff)$ {
 *      		expires 24h;
 *      		log_not_found off;
 *      		try_files $uri $uri/ @fallback;
 *      	}
 *
 *      	location @fallback {
 *      		return 302 /fallback.php?uri=$uri&args=$args;
 *      	}
 *
 *
 * Apache configuration:
 *
 * Add the following rules to a .htaccess in the webroot of the project.
 *
 *
 *          <FilesMatch "\.(png|jpg|jpeg|svg|webp|gif|ico|mp3|mp4|mov|tif|tiff)$">RewriteEngine On
 *              RewriteCond %{HTTP_HOST} ^.*prouddevelopment.*$ [NC]
 *              RewriteCond %{REQUEST_FILENAME} !-f
 *              RewriteCond %{REQUEST_FILENAME} !-d
 *              RewriteRule (.*) /fallback.php/?uri=%{REQUEST_URI}&args=%{QUERY_STRING} [L]
 *          </FilesMatch>
 */
const LIVE_URL = 'https://www.proudnerds.com';

$uri = $_GET['uri'];
$args = $_GET['args'];

header('Location: '.LIVE_URL.$uri.'?'.$args);

exit;
