Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我部署了一个站点并尝试登录,例如在www.website.com上,但是当我转到website.com时没有登录信息
如何使两个域相同?
非常感谢。
您不需要域名服务器来完成此操作,您只需使用 .htaccess 文件即可。
在文件中,放入以下行:
RewriteEngine On RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
它的作用是查看用户输入的 URL,如果它没有以它开头,www.那么它会将其添加到 URL 并重定向。所以进入website.com,会重定向到www.website.com。
www.