0

これらのダミーのドメイン名がexample1.comあり、example1.net利用できる場合。.htaccessファイルとmod_rewriteモジュールを使用して、以下のようにリダイレクトします。

example1.com -> www.example1.com
example1.net -> www.example1.com
www.example1.net -> www.example1.com

私はこれである最初のタスクを達成しました:

RewriteEngine on
RewriteCond %{HTTP_HOST} example1\.com [NC]
RewriteCond %{HTTP_HOST} !^www\.example1\.com [NC]
RewriteRule ^(.*) http://www.example1\.com/$1 [L,R=301]

残りはどうですか?

4

1 に答える 1

0

自分でできました。ルールがどれだけうまく書かれているかわからない:

RewriteEngine on
RewriteCond %{HTTP_HOST} example1\.com [NC]
RewriteCond %{HTTP_HOST} !^www\.example1\.com [NC]
RewriteRule ^(.*) http://www.example1\.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} example1\.net [NC]
RewriteCond %{HTTP_HOST} !^www\.example1\.com [NC]
RewriteRule ^(.*) http://www.example1\.com/$1 [L,R=301]

RewriteCond %{HTTP_HOST} www\.example1\.net [NC]
RewriteRule ^(.*) http://www.example1\.com/$1 [L,R=301]

訂正するか、より良い答えを提案してください

于 2012-08-18T09:25:00.250 に答える