3

htaccess 301 リダイレクトの助けが必要です。

サイト www.site.com を持っていますが、すべてのページを www.newsite.com に変更する必要がありますが、www.site.com を移動したくありません (ページ情報について)

例:

www.site.com (not move) index of to put then a template or message

www.site.com/2012/08/page.html move to www.newsite.com/2012/08/page.html
www.site.com/tag/keyword/ move to www.newsite.com/tag/keyword/
www.site.com/category/general/ move to www.newite.com/category/general/

どうすればそれができますか?ありがとう

4

2 に答える 2

4

mod_alias を使用RedirectMatchして、リダイレクトの URI に何かを強制することができます。site.com のドキュメント ルートにある htaccess ファイルに、次を追加します。

RedirectMatch 301 ^/(.+)$ http://www.newsite.com/$1

これにより、その後http://www.site.com/はリダイレクトされますが、リダイレクトされhttp://www.site.com/ません。ただし、リダイレクトされますhttp://www.site.com/index.html それが問題になる場合は、mod_rewrite を使用できます。

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_URI} !^/index.html$
# and whatever else you don't want redirected
RewriteRule ^(.*)$ http://www.newsite.com/$1 [L,R=301]
于 2012-08-17T02:35:09.847 に答える
2

www.site.comホストで mod_rewrite と .htaccess を有効にしてから、このhttpd.confコードをディレクトリの.htaccess下に配置します。DOCUMENT_ROOT

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?site\.com$ [NC]
RewriteRule ^.+$ http://www.newsite.com%{REQUEST_URI} [L,R=301]
于 2012-08-17T02:34:38.273 に答える