1

新しいサーバー構造に移行しているので、htaccessのサポートが必要です。私はPHPプログラマーであり、決してapacheの専門家ではありません。

わかりやすい説明は次のとおりです。

  • ルートディレクトリwww.newsite.comにリダイレクトするには、www.oldsite.comのルートディレクトリが必要です。

  • newdomain.newsite.comのように、新しいサイトのサブドメインにリダイレクトする特定のディレクトリwww.oldsite / dir1

  • その他すべてwww.oldsite.com/whatever/はapps.newsite.com/whatever/にアクセスする必要があります

私が今持っているのは:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule / http://www.newsite.com [L,R=301]
RewriteRule (.*)dir1/ http://newdomain.newsite.com [L,R=301]
RewriteRule (.*)$ http://apps.newsite.com/$1 [L,R=301]

しかし、私が望むように機能していません...

とにかく、ありとあらゆる助けをいただければ幸いです。

ありがとう、-Orallo

4

2 に答える 2

0

最初の書き直しが問題を引き起こし、基本的にすべてをリダイレクトしていました。

これはあなたが望むことをするはずです:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^/?$ http://www.newsite.com [L,R=301]
RewriteRule ^/?dir1/(.*) http://newdomain.newsite.com/$1 [L,R=301]
RewriteRule ^/?(.*)$ http://apps.newsite.com/$1 [L,R=301]

この一連の書き換えルールをこのホストの実際のApacheconfファイルに入れてオフにすることをお勧めします。これAllowOverrideにより、パフォーマンスが向上します。本質的に、古いサイトのWebディレクトリを使用しなくなったため、Apacheサーバーでそのディレクトリ(およびまだ存在する可能性のある他の子ディレクトリ)を調べて.htaccessファイルを見つける理由はありません。

于 2012-09-13T17:29:10.087 に答える
0

mod_aliasを使用すると、これをserver / vhost構成またはhtaccessファイル(oldsite.comのドキュメントルート)に配置できます。

Redirect 301 /dir1 http://newdomain.newsite.com
RedirectMatch 301 ^/(.+)$ http://apps.newsite.com/$1
RedirectMatch 301 ^/$ http://www.newsite.com

mod_rewriteに関しては、htaccessファイルで使用しているため、リライトルールから先頭のスラッシュを削除する必要があります。

RewriteEngine On
RewriteBase /
RewriteRule ^$ http://www.newsite.com [L,R=301]
RewriteRule ^dir1/(.*) http://newdomain.newsite.com/$1 [L,R=301]
RewriteRule ^(.+)$ http://apps.newsite.com/$1 [L,R=301]
于 2012-09-13T17:29:16.263 に答える