Manual:Short URL/ja

Short URLs（別名：URL Rewrites）とは、ページのURLから と言った文字を隠すための機能です. 後で問題を減らすために、始める前に、あなたのウェブサイトの安定した URL構造 を得るのに数分掛かります.

目標
MediaWikiの一般的なインストレーション・パスは、大体以下のようなパスになります.
 * （管理者ユーザーとしてインストールした場合）
 * （共有プロパイダにインストールした場合）

MediaWikiのデフォルトのウェブページアドレスは以下の例のようになります.
 * （CGIサポートのない場合）
 * （CGIサポートのある場合）

下記の方法を使用して、ウェブページのアドレスを次のように短くすることができます.
 * も一般的な設定. サーバーの設定の変更を必要とするので、デフォルトではありません.
 * （推奨されません. 詳細は下記をご覧ください. ）
 * （推奨されません. 詳細は下記をご覧ください. ）
 * （推奨されません. 詳細は下記をご覧ください. ）
 * （推奨されません. 詳細は下記をご覧ください. ）

※ファイルや、下位ディレクトリ等と衝突する為、ドメイン下のルートに直接ページパスを置かないことをお勧めします. 例えば、 ディレクトリに画像ファイルを置くと、 （ を にしている場合） "Images"という記事名を持つ記事にアクセスできなくなります.

長所と短所

 * 長所: 技術的詳細を全て不可視化. 通常それは、最善慣行とされる事です. 特に、基本ソフトウェアを変える場合でも、システムを安定に保つことができます. They are also easier to read, remember, and manipulate for visitors. also, short URLs are better than default one to SEO because URLs includes   is minus to SEO.
 * 短所: 設定が必要. 使用しているホスティング環境によっては、再作成が困難になる場合があります. しかし、広く使用されているWebサーバーは殆ど、短いURLが使えます. 実際、有料サーバーは全て、この機能をサポートしています. またこの機能をサポートしていないホストには、お金を払う価値は無いでしょう.

ガイド
Webサーバー別短縮URL設定公式ガイド. この中から、お使いのWebサーバーを選択します. 使用しているサーバーソフトが分からない場合、Apacheの可能性が高いでしょう.


 * ../Apache/ja/ - Apache、LiteSpeedの短縮URLの設定方法を紹介.

他サーバー用ガイド

 * 公式ガイドが上記の別のWebサーバー向けに作られている事等からも分かる通り、以下のガイドは情報が古く、現時点では殆ど役に立ちません. 最終的には、多分以下のガイドは削除されます.

誰でも解説ページを作り、それを下のリストに載せることができます. 新しい解説ページを作るときは、下のページを参考にしながら、適切なページ名で作るよう心がけて下さい. それぞれの解説に独自のページがある場合、読者は嫌な複雑な作業をスキップすることができます. 解説ページは、簡潔に、読みやすくするように心がけて下さい.

To help others find out which Short URL methods really work, after trying each method please edit the page and increase the "worked" or "didn't_work" numbers for that guide and make a brief (or long, your choice) description on what went wrong by clicking the link on your number.

ルート アクセス
These methods require that you have access to the server configuration. If you are on a shared host, you most likely don't. In this case you will be required to use a method that requires "no root access". You can jump directly to the MediaWiki ShortURL Builder tool and follow the on screen instructions after clicking on "I don't have root access".

(for Apache guidance, see the link in the Guides section).

example.com/Page_title - のような URL
example.com/Page_title URL の作成方法:

wiki.example.com/Page_title - のような URL
wiki.example.com/Page_title URL の作成方法:

アンパサンド(&)問題
The ampersand problem shows up when you have page titles with symbols in (such as &, ?, #, + and /) that, despite being correctly encoded in the link are not being passed correctly from mod_rewrite to the script. This manifests in 404 page-not-found errors, because the title gets cut off at the special character. For example, clicking on a link to "John & Maria's page" gets a 404, because MediaWiki is looking for a page named "John ".

This is because ampersands in long-form names are treated as query string separators, and would never reach the PHP runtime environment. This is caused by an old and problematic mod_rewrite bug.

解決方法:

This issue is caused by the  portion of rewrite rules like   which is completely unnecessary and harmful. MediaWiki parses paths directly from the REQUEST_URI so rewrite everything to /index.php.

No Skins
With Ubuntu 8.10 and Mediawiki 1.11.2 (and maybe later versions) if you use the Mediawiki sanctioned directions your skins may fail to load. To fix this, create a symbolic link in /var/www pointing to /var/lib/mediawiki with the value of $wgScriptPath in LocalSettings.php. If, for example, $wgScriptPath is set to "/w" then you need to run the command "sudo ln -s /var/lib/mediawiki /var/www/w".

Alternatively, try setting $wgLoadScript to the original file. If you source url is /wiki with the short url /w, set it to /wiki/load.php.

Purging cache
If you notice that your changes to  in LocalSettings.php are not being reflected in mysite.com/wiki/Main_Page, it may be due MediaWiki's caching of the links according to previous settings.

Go to mysite.com/wiki/Main_Page?action=purge to force MediaWiki to regenerate the cached links.

Also you can:
 * 1) execute the MySQL query "TRUNCATE objectcache;", or
 * 2) Ensure  is updated (if  is enabled all you have to do is edit LocalSettings.php to purge it)

Redirect visitor of your domain to your wiki
Our official guides for short url configuration include recommendations on how to point the root of your site to your wiki using your short url config.

For example our Apache guide recommends using this to point your site root to your wiki:

Note that we do not recommend doing a HTTP redirect to your wiki path or main page directly. As redirecting to the main page directly will hard-code variable parts of your wiki's page setup into your server config. And redirecting to the wiki path will result in two redirects. Simply rewrite the root path to MediaWiki and it will take care of the 301 redirect to the main page itself.

If using VirtualHosts, place the rewrite rules into the virtual host declaration!

Moving a wiki from /wiki to /w
A common beginners mistake is to install MediaWiki itself (the source code, not the short url) in  instead of. Once installed they would realize the mistake when trying to configure Short URLs (which would become difficult as the virtual path then conflicts with the real path).

There is a manual for moving a wiki in general, however that is too complicated if all you need is to change the installation directory (and stay on the same server, same database and same hostname).

Here is what you have to do:


 * Backup  and any other config files you may have created (such as your  ).
 * Rename the installation directory of MediaWiki on your server from  to.
 * Set  in   to   and remove (or comment out) any definition of   (this variable will be changed again when setting up Short URLs, further on)
 * At this point your wiki should be working normally at
 * Now go through the regular guide to set up short URLs
 * Perform a few tests on your wiki to make sure nothing is broken. Edit a page, visit a few different pages, etc. If anything seems abnormal, revert the changes by restoring your backup of  and other relevant files you might have changed during configuration of short URLs and rename your folder back to.

Note for shared hosting users: Many shared hosting plans offer an application manager to automatically Install, Update and Backup applications such as MediaWiki. If your plan has this and if you want to keep using these features, you should contact their tech support and let them know you just manually changed your MediaWiki installation directory.

関連項目

 * Explanation of what CGI modules are
 * $wgUsePathInfo - configuration setting that defines whether to use 'pretty' URLs or not
 * Notes on placing your wiki installation in site root directory
 * $wgActionPaths - configuration setting that you can use to define 'pretty' URLs for other actions, like edit or history
 * Clean up URLs RFC - proposes "cleaner URLs for editing, previewing skins, etc."

外部リンク

 * Apache Module mod_rewrite at Apache.org
 * MediaWiki Short URL Builder Tool - A tool that can automatically generate short url configuration more reliable than the configurations in these manual pages.