Manual:$wgServer/ja
From MediaWiki.org
| 一般的な設定: $wgServer | |
|---|---|
| サーバのベースURL |
|
| 導入されたバージョン: | pre 1.1.0 |
| 削除されたバージョン: | 使用中 |
| 可能な値: | URL 接頭辞 (protocol, host, optional port; no path portion) |
| デフォルトの値: | (動的に生成されます) |
[edit] 詳細
プロトコルを含み、後に続くスラッシュなしのサーバのベースURL。 (例として "http://www.mediawiki.org")
これはwikiを示す省略されていないURLを生成するときに使用されています、事例としては:
- HTTP redirects on edit and to canonical URL spellings
- print footer
- links to articles from RSS/Atom feeds
- and more!
デフォルト値は(それを無効にすることができますが)自動的に計算されます。下記の詳細をご覧下さい。
いくつかのウェブサーバーは結局、望んでもいない、ばかげたデフォルトか内部名を返します;シ例えば、アパッチでのhttpd.confのServerNameディレクティブは、予想もしていない'localhost'を残して、設定しないか、システムによる適切な検出をすることができません。適切にウェブサーバーを構成する事を推奨しますが、LocalSettings.php を手動で設定する事により無効にする事も出来ます。
手動設定での無効化は、特定の共有された hosting 又は proxyingのコンフィギュレーションに役立てる事も出来ます。
[edit] 関連項目
Contents |
[edit] 履歴
[edit] Before 1.2.0
getenv( "SERVER_NAME" );をコールする事により計算されました。
[edit] 1.2.0
getenv() の代わりにPHPの $_SERVER[] 配列の使用に切り替えられています。自動的にポートナンバーを算定しています。
$wgServer = "http://" . $_SERVER["SERVER_NAME"]; if( $_SERVER["SERVER_PORT"] != 80 ) $wgServer .= ":" . $_SERVER["SERVER_PORT"];
[edit] 1.3.0
動的にプロトコルを算定するためのコードが追加されています。コマンドラインから走らせたときに、適当なデフォルト値を使用するようにしています。
# check if server use https: $wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; if ( @$wgCommandLineMode ) { $wgServer = $wgProto.'://localhost'; } else { $wgServer = $wgProto.'://' . $_SERVER['SERVER_NAME']; if( $_SERVER['SERVER_PORT'] != 80 ) $wgServer .= ":" . $_SERVER['SERVER_PORT']; } unset($wgProto);
[edit] 1.3.8
$_SERVER[] 配列から、より詳細な内容を得るようにしています。
if( isset( $_SERVER['SERVER_NAME'] ) ) { $wgServerName = $_SERVER['SERVER_NAME']; } elseif( isset( $_SERVER['HOSTNAME'] ) ) { $wgServerName = $_SERVER['HOSTNAME']; } else { # FIXME: Fall back on... something else? $wgServerName = 'localhost'; } # check if server use https: $wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; $wgServer = $wgProto.'://' . $wgServerName; if( isset( $_SERVER['SERVER_PORT'] ) && $_SERVER['SERVER_PORT'] != 80 ) { $wgServer .= ":" . $_SERVER['SERVER_PORT']; } unset($wgProto);
[edit] 1.5.0
HTTPSプロトコルでのデフォルトポートでそれを変更する前かどうかに関係なく、初期テストが失敗するか、確認のための $wgServerName のためにいくつかの付加的な代替手段を追加しています。
if( isset( $_SERVER['SERVER_NAME'] ) ) { $wgServerName = $_SERVER['SERVER_NAME']; } elseif( isset( $_SERVER['HOSTNAME'] ) ) { $wgServerName = $_SERVER['HOSTNAME']; } elseif( isset( $_SERVER['HTTP_HOST'] ) ) { $wgServerName = $_SERVER['HTTP_HOST']; } elseif( isset( $_SERVER['SERVER_ADDR'] ) ) { $wgServerName = $_SERVER['SERVER_ADDR']; } else { $wgServerName = 'localhost'; } # check if server use https: $wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; $wgServer = $wgProto.'://' . $wgServerName; # If the port is a non-standard one, add it to the URL if( isset( $_SERVER['SERVER_PORT'] ) && ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 ) || ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) { $wgServer .= ":" . $_SERVER['SERVER_PORT']; } unset($wgProto);
[edit] 1.7.0
唯一の変更は、既にコロンを含んでいるならポートをサーバ名に追加しないということです。
/** URL of the server. It will be automatically built including https mode */ $wgServer = ''; if( isset( $_SERVER['SERVER_NAME'] ) ) { $wgServerName = $_SERVER['SERVER_NAME']; } elseif( isset( $_SERVER['HOSTNAME'] ) ) { $wgServerName = $_SERVER['HOSTNAME']; } elseif( isset( $_SERVER['HTTP_HOST'] ) ) { $wgServerName = $_SERVER['HTTP_HOST']; } elseif( isset( $_SERVER['SERVER_ADDR'] ) ) { $wgServerName = $_SERVER['SERVER_ADDR']; } else { $wgServerName = 'localhost'; } # check if server use https: $wgProto = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https' : 'http'; $wgServer = $wgProto.'://' . $wgServerName; # If the port is a non-standard one, add it to the URL if( isset( $_SERVER['SERVER_PORT'] ) && !strpos( $wgServerName, ':' ) && ( ( $wgProto == 'http' && $_SERVER['SERVER_PORT'] != 80 ) || ( $wgProto == 'https' && $_SERVER['SERVER_PORT'] != 443 ) ) ) { $wgServer .= ":" . $_SERVER['SERVER_PORT'];

