summaryrefslogtreecommitdiff
path: root/application/config
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2009-06-08 23:02:16 -0700
committerBharat Mediratta <bharat@menalto.com>2009-06-08 23:02:16 -0700
commit47810c9aec1e6b190a1a90505899669a2c89b770 (patch)
tree5b3babcc13844d13137e44107297099209250893 /application/config
parent1ecdb5ef0c82272d8019e4b7d834432f73baf474 (diff)
Try again to properly detect the base url, taking into account the
sites that mangle SCRIPT_NAME
Diffstat (limited to 'application/config')
-rw-r--r--application/config/config.php20
1 files changed, 18 insertions, 2 deletions
diff --git a/application/config/config.php b/application/config/config.php
index d274a31b..2d66d1c0 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -22,9 +22,25 @@
* Base path of the web site. If this includes a domain, eg: localhost/kohana/
* then a full URL will be used, eg: http://localhost/kohana/. If it only includes
* the path, and a site_protocol is specified, the domain will be auto-detected.
+ *
+ * Here we do our best to autodetect the base path to Gallery. If your url is something like:
+ * http://example.com/gallery3/index.php/album73/photo5.jpg?param=value
+ *
+ * We want the site_domain to be:
+ * /gallery3
+ *
+ * In the above example, $_SERVER["SCRIPT_NAME"] contains "/gallery3/index.php" so
+ * dirname($_SERVER["SCRIPT_NAME"]) is what we need. Except some low end hosts (namely 1and1.com)
+ * break SCRIPT_NAME and it contains the extra path info, so in the above example it'd be:
+ * /gallery3/index.php/album73/photo5.jpg
+ *
+ * So dirname doesn't work. So we do a tricky workaround where we look up the SCRIPT_FILENAME (in
+ * this case it'd be "index.php" and we delete from that part onwards. If you work at 1and1 and
+ * you're reading this, please fix this bug!
*/
-$config["site_domain"] = dirname(
- empty($_SERVER["ORIG_SCRIPT_NAME"]) ? $_SERVER["SCRIPT_NAME"] : $_SERVER["ORIG_SCRIPT_NAME"]);
+$config["site_domain"] =
+ substr($_SERVER["SCRIPT_NAME"], 0,
+ strpos($_SERVER["SCRIPT_NAME"], basename($_SERVER["SCRIPT_FILENAME"])));
/**
* Force a default protocol to be used by the site. If no site_protocol is