古いサーバーをarchive.example.comに移動しています。新しいサーバーはexample.comで実行され続けますが、すべてのwww URLはexample.comまたはarchive.example.comのいずれかに正規化されており、末尾スラッシュ問題。RewriteRule:古いパスをアーカイブサーバーにリダイレクトし、www以外のドメインに正規化しますか?
古いサーバーには多数のディレクトリがあるため、新しいサーバーで実行されるいくつかのディレクトリを除いて、すべてがパス情報を保持しながらarchive.example.comにリダイレクトする必要があります。私はリダイレクトしたくないと、新しいサーバ用に残りますディレクトリは、次のとおりです。たとえば
/(root) /static /blog /about
:
example.com => example.com www.example.com => example.com www.example.com/ => example.com/ example.com/blog => example.com/blog www.example.com/blog => example.com/blog www.example.com/blog/ => example.com/blog/
他のすべてのディレクトリはarchive.example.comにリダイレクトする必要があります。例:ここでは
example.com/docs => archive.example.com/docs www.example.com/docs => archive.example.com/docs www.example.com/docs/ => archive.example.com/docs/ example.com/library/images => archive.example.com/library/images www.example.com/library/images => archive.example.com/library/images www.example.com/library/images/ => archive.example.com/library/images/
は、私は私のhttpd.confファイルに持っているものです。
ServerName example.com
ServerAlias www.example.com
UseCanonicalName On
# canonicalize www.example.com to example.com
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ $1 [R=301]
# redirect everything to archive.example.com except for a few directories
RewriteCond %{REQUEST_URI} !^(/|/static|/blog|/about)$
RewriteRule ^/(.*)$ http://archive.example.com/$1 [NC,R=301,L]
は、この正しいです、および/またはより正確な方法は何ですか?