0

我在http://www.artsplash.in有我的网站,我试图将我的网站的非 www 版本重定向到 www 版本(我不知道我的服务器是否在我不知情的情况下自己做相反的事情)。我已经将 .htaccess 文件作为

# DO NOT REMOVE THIS LINE AND THE LINES BELOW HOTLINKID:nunaquvaQe
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^http://artsplash.in/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://artsplash.in$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.artsplash.in/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.artsplash.in$      [NC]
RewriteRule .*\.(1)$ http://www.artsplash.in [R,NC]
# DO NOT REMOVE THIS LINE AND THE LINES ABOVE nunaquvaQe:HOTLINKID


# DO NOT REMOVE THIS LINE AND THE LINES BELOW REDIRECTID:anajuqehyv
RewriteEngine on
RewriteCond %{HTTP_HOST} ^artsplash.in$ [OR]
RewriteCond %{HTTP_HOST} ^www.artsplash.in$
RewriteRule ^mail$ http://webmail1.nazuka.net/roundcube/ [R=301,L]
# DO NOT REMOVE THIS LINE AND THE LINES ABOVE anajuqehyv:REDIRECTID


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^login$ wp-login.php
RewriteRule ^register$ wp-login.php?action=register
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress 

我自己为重定向到 www.artsplash.in 所做的任何事情都会导致浏览器消息显示该站点具有重定向循环。我究竟应该在我的 .htaccess 文件中添加什么以获得所需的结果?- 非常需要帮助。

4

1 回答 1

0

您必须在 htaccess 文件中使用此代码以首选 www 版本:

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

为了更好的 SEO:如果您的网站已添加到 Google 网站管理员工具中,您可以在 Google 网站管理员工具中设置您的首选域:

打开您的网站管理员工具,然后单击“配置”下方的“设置”。在右侧查找“首选域”,然后选择您喜欢使用 www 或不使用的域。

于 2013-06-15T09:51:51.840 回答