Skip to content

Instantly share code, notes, and snippets.

@rexfng
Forked from lavoiesl/paths.php
Created September 1, 2016 22:58
Show Gist options
  • Save rexfng/2c0ab693769f26b390fce634d36b12f0 to your computer and use it in GitHub Desktop.
Save rexfng/2c0ab693769f26b390fce634d36b12f0 to your computer and use it in GitHub Desktop.

Revisions

  1. @lavoiesl lavoiesl revised this gist Jul 15, 2015. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions paths.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    <?php

    $base_dir = __DIR__; // Absolute path to your installation, ex: /var/www/mywebsite
    $doc_root = preg_replace("!{$_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); # ex: '' or '/mywebsite'
    $doc_root = preg_replace("!${_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $base_url = preg_replace("!^${doc_root}!", '', $base_dir); # ex: '' or '/mywebsite'
    $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
    $port = $_SERVER['SERVER_PORT'];
    $disp_port = ($protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443) ? '' : ":$port";
    $domain = $_SERVER['SERVER_NAME'];
    $full_url = "$protocol://{$domain}{$disp_port}{$base_url}"; # Ex: 'http://example.com', 'https://example.com/mywebsite', etc.
    $full_url = "${protocol}://${domain}${disp_port}${base_url}"; # Ex: 'http://example.com', 'https://example.com/mywebsite', etc.
  2. @lavoiesl lavoiesl revised this gist Feb 27, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion paths.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php

    $base_dir = __DIR__; // Absolute path to your installation, ex: /var/www/mywebsite
    $doc_root = preg_replace("!{$_SERVER['PHP_SELF']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $doc_root = preg_replace("!{$_SERVER['SCRIPT_NAME']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); # ex: '' or '/mywebsite'
    $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
    $port = $_SERVER['SERVER_PORT'];
  3. @lavoiesl lavoiesl revised this gist Feb 20, 2013. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions paths.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    <?php

    $base_dir = __DIR__; // Absolute path to your installation, ex: /var/www/mywebsite
    $doc_root = preg_replace("!{$_SERVER['PHP_SELF']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); # ex: '' or '/mywebsite'
    $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
    $srv_port = $_SERVER['SERVER_PORT'];
    $port = ($protocol == 'http' && $srv_port == 80 || $protocol == 'https' && $srv_port == 443) ? '' : ":$srv_port";
    $domain = $_SERVER['SERVER_NAME'];
    $full_url = "$protocol://$domain$port$base_url"; # Ex: 'http://example.com', 'https://example.com/mywebsite', etc.
    $base_dir = __DIR__; // Absolute path to your installation, ex: /var/www/mywebsite
    $doc_root = preg_replace("!{$_SERVER['PHP_SELF']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); # ex: '' or '/mywebsite'
    $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
    $port = $_SERVER['SERVER_PORT'];
    $disp_port = ($protocol == 'http' && $port == 80 || $protocol == 'https' && $port == 443) ? '' : ":$port";
    $domain = $_SERVER['SERVER_NAME'];
    $full_url = "$protocol://{$domain}{$disp_port}{$base_url}"; # Ex: 'http://example.com', 'https://example.com/mywebsite', etc.
  4. @lavoiesl lavoiesl created this gist Feb 20, 2013.
    10 changes: 10 additions & 0 deletions paths.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <?php

    $base_dir = __DIR__; // Absolute path to your installation, ex: /var/www/mywebsite
    $doc_root = preg_replace("!{$_SERVER['PHP_SELF']}$!", '', $_SERVER['SCRIPT_FILENAME']); # ex: /var/www
    $base_url = preg_replace("!^{$doc_root}!", '', $base_dir); # ex: '' or '/mywebsite'
    $protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
    $srv_port = $_SERVER['SERVER_PORT'];
    $port = ($protocol == 'http' && $srv_port == 80 || $protocol == 'https' && $srv_port == 443) ? '' : ":$srv_port";
    $domain = $_SERVER['SERVER_NAME'];
    $full_url = "$protocol://$domain$port$base_url"; # Ex: 'http://example.com', 'https://example.com/mywebsite', etc.