From 82019d89fb67be280a12a98d97ad0a6651539a0c Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 31 May 2003 13:05:06 +0000 Subject: - Omit "index.php" when using Apache. Patch by Al. --- includes/common.inc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index 66152b3c4..aeec31e8a 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -840,18 +840,29 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $ function url($url = NULL, $query = NULL) { global $base_url; + static $script; + + if (empty($script)) { + /* + ** On some webservers such as IIS we can't omit "index.php". As such we + ** generate "index.php?q=foo" instead of "?q=foo" on anything that is not + ** Apache. + */ + $script = (strpos($_SERVER["SERVER_SOFTWARE"], "Apache") === false) ? "index.php" : ""; + } + if (variable_get("clean_url", "0") == "0") { if (isset($url)) { if (isset($query)) { - return "$base_url/index.php?q=$url&$query"; + return "$base_url/$script?q=$url&$query"; } else { - return "$base_url/index.php?q=$url"; + return "$base_url/$script?q=$url"; } } else { if (isset($query)) { - return "$base_url/index.php?$query"; + return "$base_url/$script?$query"; } else { return "$base_url/"; @@ -869,7 +880,7 @@ function url($url = NULL, $query = NULL) { } else { if (isset($query)) { - return "$base_url/index.php?$query"; + return "$base_url/$script?$query"; } else { return "$base_url/"; -- cgit v1.2.3