html - WWW 和非 WWW URL。两个不同的站点

标签 html redirect

我今天才注意到我正在创建的网站存在 WWW 或非 WWW 问题。如果您访问 http://www.taskconductor.com,它是一个与 http://taskconductor.com 具有相同内容的不同页面。

如果您要在 http://www.taskconductor.com 登录(用户名:show@412customs.com,通过:tester),然后尝试转到 http://taskconductor.com(没有 WWW),它会让你重新登录。然后你可以看到,当你检查你的 cookie 时,你可以看到有两组 cookie。一个用于 http://taskconductor.com,一个用于 http://www.taskconductor.com。

我已经看到这是一个问题,但我需要进行重定向吗?如果是这样,它必须是 index.php 吗?我真的更愿意将我所有的主要内容放在 index.php 上。

我该如何解决这个问题?

最佳答案

您知道您使用的是什么网络服务器吗?如果您使用的是 apache,则可以重写 .htaccess 文件中的 URL。这将允许您将所有流量集中到您的非 www 域。我快速谷歌了一下,找到了这个示例代码:

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

来源:http://yoast.com/how-to-remove-www-from-your-url-with-mod_rewrite/

关于html - WWW 和非 WWW URL。两个不同的站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6554267/

相关文章:

javascript - Onload 不起作用 : Uncaught reference error, 函数未定义

redirect - init 中的 yii2 重定向是否有效?

spring - 如何在使用 Spring MVC 时使用 send.redirect()

redirect - Nginx反向代理导致无限循环

html - 将包含图像叠加层的图像分组到页面中心

包含关键字/保留字的 PHP MySQL 查询

html - margin : 0 auto; not centering when there is a width

javascript - 宏弹出式YouTube视频未链接

java - Struts2 重定向具有哈希值的 url

.htaccess - 如何将.htaccess重定向用于部分路径?