2016-05-10 8 views
2

を除外します1つのファイル(myfile.html)それが正常に動作していないいくつかの理由についての.htaccessは<strong>robots.txtの</strong>と1、私は新しいドメインに、古いドメインをリダイレクトするが、<strong>非WWWホームページ</strong>を残すようにしようとしています新しいドメインに、古いドメインをリダイレクトするが、非WWW版、robots.txtの1つのファイル

RewriteEngine on 
RewriteCond %{HTTP_HOST} !^www\. 
RewriteCond %{REQUEST_URI} !/(myfile\.html|robots\.txt) [NC] 
RewriteRule ^$ http://olddomanin.com [R=410,L] 
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L] 

:ここ は私がここ

all www.olddomain.com > all www.newdomain.com 
olddomain.com > 404 error 
olddomain.com/robots.txt > olddomain.com/robots.txt 
olddomain.com/myfile.html > olddomain.com/myfile.html 

を行うにしようとしていますものです、私は下にしようとしているものです。

答えて

1

ルート.htaccessファイルに次のコードを入れてください:

RewriteEngine on 

RewriteCond %{HTTP_HOST} !^www\. 
RewriteCond %{REQUEST_URI} !/(myfile\.html|robots\.txt) [NC] 
RewriteRule ^(.*)$ /$1 [R=404,L] 

# above code will capture any request not having www except myfile.html & 
# robots.txt and directed to 404 error page and if you want 410 change it 

RewriteCond %{REQUEST_URI} !/(myfile\.html|robots\.txt) [NC] 
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L] 

# the above code will capture every request that passed the above rule 
# except myfile.html & robots.txt and redirected it to a new domain 
関連する問題