.htaccess文件中下面的代碼應該是,等我想,對重定向主域名的二級域名:的.htaccess域名轉發問題
<ifModule mod_headers.c>
Header unset Last-Modified
</ifModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^secondaryDomain1.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain1.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain2.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain2.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain3.com$ [OR]
RewriteCond %{HTTP_HOST} ^secondaryDomain3.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain4.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain4.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain5.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain5.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain6.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain6.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^secondaryDomain7.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.secondaryDomain7.com$
RewriteRule ^/?$ "http\:\/\/mainDomain\.com\/" [R=301,L]
不幸的是如果我鍵入www.secondaryDomain.com /index.html或www.secondaryDomain.com/directory它不會重定向到主域。 .htacess文件中做了什麼錯誤?
謝謝@拉斯,我想我越來越近;現在如果我輸入www.secondarydomain.com/index.html,它似乎嘗試重定向到mainDomain.comindex.html。如果我輸入www.secondaryDomain.com/directory,但我沒有重定向。 – tje 2011-04-07 14:21:54
@Laas,我已經使用'RewriteRule(。*)「http \:\/\/mainDomain \ .com \/$ 1」[R = 301,L]'並且它正確地重定向「www.secondaryDomain.com/ index.html。因此,這個問題的一半已經解決了,謝謝! – tje 2011-04-07 14:27:56
啊哈!「RewriteBase /」從網址的開頭抓起了斜槓,所以是的,你的解決方案是正確的。 – Laas 2011-04-07 14:30:41