我在mycompany.tld1上有一个现有的Wordpress站点设置,最近注册了mycompany.tld2。
我想设置从mycompany.tld2到mycompany.tld1的301redirect,那个.htaccess文件是什么样的? 我可以使用条件语句将它附加到Wordpress .htaccess文件中以检查入站URL吗?
WP .htaccess(现有):
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
如果你想从mycompany.tld2redirect到mycompany.tld1,.htaccess看起来有点像这样。
<IfModule mod_alias.c> RedirectPermanent / http://mycompany/tld1/ </IfModule>
redirect不是您主要的所有域:
RewriteCond %{HTTP_HOST} !^www\.example\.tld1 [NC] RewriteRule ^(.*)$ http://www.example.tld1/$1 [R=301,L]
只将辅助TLDredirect到主要:
RewriteCond %{HTTP_HOST} ^www\.example\.tld2 [NC] RewriteRule ^(.*)$ http://www.example.tld1/$1 [R=301,L]
在你的.htaccess文件中,我build议把这些放在RewriteBase /