【问题标题】:Redirecting non www version of my site to www version results in a redirect loop将我的网站的非 www 版本重定向到 www 版本会导致重定向循环
【发布时间】:2013-06-07 02:59:47
【问题描述】:

我的网站位于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 文件中添加什么以获得所需的结果? - 非常需要帮助。

【问题讨论】:

    标签: .htaccess redirect http-status-code-301


    【解决方案1】:

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

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

    为了更好的 S.E.O: 如果您的网站是在 Google 网站管理员工具中添加的,您可以在 Google 网站管理员工具中设置您的首选域:

    打开您的网站管理员工具,然后点击“配置”下方的“设置”。在右侧查找“首选域”,然后选择您喜欢的域是否带有 www。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-12
      • 1970-01-01
      • 2011-04-02
      • 1970-01-01
      • 2015-05-01
      • 1970-01-01
      相关资源
      最近更新 更多