1

サイトを Mediawiki から Wordpress に移動し、このページをリダイレクトしたいと考えています:

http://wecheck.org/wiki/Aaron_Swartz

このページへ:

http://newslines.org/wiki/category/computer-people/aaron-swartz/

現在、私が持っている.htaccessにあります

Options +FollowSymlinks
RewriteEngine on 

RewriteCond %{QUERY_STRING} ^title=Aaron_Swartz$
RewriteRule ^/w/index\.php$ http://newslines.org/wiki/category/computer-people/aaron-swartz/? [L,R=301]


RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/w/index.php [L]
RewriteRule ^/?$ %{DOCUMENT_ROOT}/w/index.php [L]

2 番目の部分は、mediawiki のきれいな URL を作成します。たくさんのバリエーションを試しましたが、まったく機能しません。どんな助けでも大歓迎です。

更新:指定されたソリューションを使用したログ ファイル。.phtml とは何ですか?

[24/Jan/2013:22:01:00 +0000]  init rewrite engine with requested uri /wiki/Aaron_Swartz
[24/Jan/2013:22:01:00 +0000] (1) pass through /wiki/Aaron_Swartz
[24/Jan/2013:22:01:00 +0000] (1) [perdir /var/www/] pass through /var/www/w/wiki.phtml
[24/Jan/2013:22:01:00 +0000] (3) [perdir /var/www/] add path info postfix: /var/www/w/wiki.phtml -> /var/www/w/wiki.phtml/Aaron_Swartz
[24/Jan/2013:22:01:00 +0000] (3) [perdir /var/www/] strip per-dir prefix: /var/www/w/wiki.phtml/Aaron_Swartz -> w/wiki.phtml/Aaron_Swartz
[24/Jan/2013:22:01:00 +0000] (3) [perdir /var/www/] applying pattern '^wiki/Aaron_Swartz$' to uri 'w/wiki.phtml/Aaron_Swartz'
[24/Jan/2013:22:01:00 +0000] (3) [perdir /var/www/] add path info postfix: /var/www/w/wiki.phtml -> /var/www/w/wiki.phtml/Aaron_Swartz
[24/Jan/2013:22:01:00 +0000] (3) [perdir /var/www/] strip per-dir prefix: /var/www/w/wiki.phtml/Aaron_Swartz -> w/wiki.phtml/Aaron_Swartz
[24/Jan/2013:22:01:00 +0000] (3) [perdir /var/www/] applying pattern '^w/index\.php$' to uri 'w/wiki.phtml/Aaron_Swartz'
[24/Jan/2013:22:01:00 +0000] (1) [perdir /var/www/] pass through /var/www/w/wiki.phtml
4

1 に答える 1

1

などの Apache ディレクティブRewriteRuleは、MediaWiki がリクエストを確認する前に適用されることに注意してください。したがって、現在のルールは http://wecheck.org/w/index.php?title=Aaron_Swartz では機能しますが、 http://wecheck.org/wiki/Aaron_Swartzでは機能しません。

ただし、実際には、正規表現が で始まるため、ルールは機能しません/が、.htaccess コンテキストではRewriteBase、書き換えルールが適用される前に先頭のスラッシュ (または設定したもの) が削除されます。

したがって、これら 2 つの問題を修正するには、次のようなものが必要です。

Options +FollowSymlinks
RewriteEngine On
RewriteBase /

# match the short URL of the page:
RewriteRule ^wiki/Aaron_Swartz$ http://newslines.org/wiki/category/computer-people/aaron-swartz/ [R=301,L]

# optional: also match the long version of the URL:
RewriteCond %{QUERY_STRING} ^title=Aaron_Swartz$
RewriteRule ^w/index\.php$ http://newslines.org/wiki/category/computer-people/aaron-swartz/ [R=301,L]

編集:ログ ファイルに基づいてwiki.phtml、Web サーバーのルートにファイルがあり、Apache が/wiki/.

1 つの回避策は、書き換えルールをメインの Apache 構成に移動して、そのようなマッピングが行われる前に実行することです。別のより簡単な方法は、上記の最初の書き換えルールを次のように変更することです。

# match the short URL of the page:
RewriteRule ^wiki\.phtml/Aaron_Swartz$ http://newslines.org/wiki/category/computer-people/aaron-swartz/ [R=301,L]

あるいは:

# match the short URL of the page:
RewriteRule ^wiki(\.phtml)?/Aaron_Swartz$ http://newslines.org/wiki/category/computer-people/aaron-swartz/ [R=301,L]
于 2013-01-24T15:09:24.280 に答える