为什么我的 namecheap 域被视为 https:// 和 https://www 的两个独立域?
Why is my namecheap domain treated as two seperate domains for https:// and https://www?
我才刚刚意识到,当我在 namecheap 上 https://www.mywebsite.com and then https://mywebsite.com the cookies haven't carried over from my login. Does anyone know how I set it so that all traffic to https://mywebsite.com is redirected to https://www.mywebsite.com 时?
一般来说,您不能让相同的 cookie 用于两个不同的域,除非该域在 Set-Cookie
header 中明确命名。使用放置在您网站根目录中的 .htaccess 文件查看此 answer. (Yes! https://mywebsite.com and https://www.mywebsite.com are two different domains). You will have to do a redirect from https://mywebsite.com to https://www.mywebsite.com。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/ [R=301,L]
您可以参考 NameCheap documentation 如何重定向 URL。
我才刚刚意识到,当我在 namecheap 上 https://www.mywebsite.com and then https://mywebsite.com the cookies haven't carried over from my login. Does anyone know how I set it so that all traffic to https://mywebsite.com is redirected to https://www.mywebsite.com 时?
一般来说,您不能让相同的 cookie 用于两个不同的域,除非该域在 Set-Cookie
header 中明确命名。使用放置在您网站根目录中的 .htaccess 文件查看此 answer. (Yes! https://mywebsite.com and https://www.mywebsite.com are two different domains). You will have to do a redirect from https://mywebsite.com to https://www.mywebsite.com。
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/ [R=301,L]
您可以参考 NameCheap documentation 如何重定向 URL。