From: Sébastien SAUVAGE Date: Wed, 27 Feb 2013 15:52:32 +0000 (+0100) Subject: Remove script name from URL if it's index.php X-Git-Tag: v0.0.41beta~20 X-Git-Url: https://git.immae.eu/?p=github%2Fshaarli%2FShaarli.git;a=commitdiff_plain;h=9e975d86e4d1b915b2bc87251a13f3467508ac9a Remove script name from URL if it's index.php (for better looking URLs, eg. http://mysite.com/shaarli/?abcde instead of http://mysite.com/shaarli/index.php?abcde) --- diff --git a/index.php b/index.php index b7ed370d..0590b2f6 100644 --- a/index.php +++ b/index.php @@ -427,7 +427,11 @@ function serverUrl() // (eg. http://sebsauvage.net/links/) function indexUrl() { - return serverUrl() . ($_SERVER["SCRIPT_NAME"] == '/index.php' ? '/' : $_SERVER["SCRIPT_NAME"]); + $scriptname = $_SERVER["SCRIPT_NAME"]; + // If the script is named 'index.php', we remove it (for better looking URLs, + // eg. http://mysite.com/shaarli/?abcde instead of http://mysite.com/shaarli/index.php?abcde) + if (endswith($scriptname,'index.php')) $scriptname = substr($scriptname,0,strlen($scriptname)-9); + return serverUrl() . $scriptname; } // Returns the absolute URL of current script, WITH the query.