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)
This commit is contained in:
parent
2abd39052d
commit
9e975d86e4
1 changed files with 5 additions and 1 deletions
|
@ -427,7 +427,11 @@ function serverUrl()
|
||||||
// (eg. http://sebsauvage.net/links/)
|
// (eg. http://sebsauvage.net/links/)
|
||||||
function indexUrl()
|
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.
|
// Returns the absolute URL of current script, WITH the query.
|
||||||
|
|
Reference in a new issue