Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Very simple way to get PHP URL path with subfolder.
<?php
define('APP_ROOT', __DIR__); // Change this to root dir.
define('HTTP_TYPE', (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] === 443 ? 'https' : 'http');
define('HTTP_ROOT', $_SERVER['HTTP_HOST']);
define('BASE_URL', HTTP_TYPE . '://' . HTTP_ROOT . substr(APP_ROOT, strlen($_SERVER[ 'DOCUMENT_ROOT' ])) . '/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.