问题
My MediaWiki cannot get the path of my live web server. Here is the code:
$script = $_SERVER['SCRIPT_NAME'];
$path = pathinfo( $script, PATHINFO_DIRNAME ) . '/';
$path = str_replace( '//', '/', $path );
$ext = pathinfo( $script, PATHINFO_EXTENSION );
echo "Please <a href=\"" . htmlspecialchars( $path ) . "mw-config/index." . htmlspecialchars( $ext ) . "\">enter</a>";
The localhostwebserver displays the echo as: Please <a href=wiki.website.com/mw-config/index.php\">enter</a>
,
but the live server displays the echo as Please <a href=\/mw-config/index.php\">enter</a>
How is that possible? Need help!
回答1:
If you need the url of the current page in php, I can recommend this script. I have used it successfully for years.
来源:https://stackoverflow.com/questions/7696756/mediawiki-cannot-get-path