diff options
author | Sébastien SAUVAGE <sebsauvage@sebsauvage.net> | 2013-02-27 16:52:32 +0100 |
---|---|---|
committer | Sébastien SAUVAGE <sebsauvage@sebsauvage.net> | 2013-02-27 16:52:32 +0100 |
commit | 9e975d86e4d1b915b2bc87251a13f3467508ac9a (patch) | |
tree | 735e385253b3d28a273109a9b345799800dab839 | |
parent | 2abd39052da6f5b050bb29232548f17c2ea7e2ee (diff) | |
download | Shaarli-9e975d86e4d1b915b2bc87251a13f3467508ac9a.tar.gz Shaarli-9e975d86e4d1b915b2bc87251a13f3467508ac9a.tar.zst Shaarli-9e975d86e4d1b915b2bc87251a13f3467508ac9a.zip |
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)
-rw-r--r-- | index.php | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -427,7 +427,11 @@ function serverUrl() | |||
427 | // (eg. http://sebsauvage.net/links/) | 427 | // (eg. http://sebsauvage.net/links/) |
428 | function indexUrl() | 428 | function indexUrl() |
429 | { | 429 | { |
430 | return serverUrl() . ($_SERVER["SCRIPT_NAME"] == '/index.php' ? '/' : $_SERVER["SCRIPT_NAME"]); | 430 | $scriptname = $_SERVER["SCRIPT_NAME"]; |
431 | // If the script is named 'index.php', we remove it (for better looking URLs, | ||
432 | // eg. http://mysite.com/shaarli/?abcde instead of http://mysite.com/shaarli/index.php?abcde) | ||
433 | if (endswith($scriptname,'index.php')) $scriptname = substr($scriptname,0,strlen($scriptname)-9); | ||
434 | return serverUrl() . $scriptname; | ||
431 | } | 435 | } |
432 | 436 | ||
433 | // Returns the absolute URL of current script, WITH the query. | 437 | // Returns the absolute URL of current script, WITH the query. |