我有这个.htaccess代码,用于将带有www的URL重定向到不带www的URL:
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
现在,我想通过301 http代码添加将整个网络重定向到另一个域的代码。但我不想让重定向循环。
我可以使用此代码:
RewriteCond %{HTTP_HOST} !domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
谢谢。