[英]Wordpress Login via www and non-www
My Wordpress installation appears to only like logging people in using the www. 我的Wordpress安装似乎只喜欢使用www登录。 subdomain and forces the www.
子域并强制www。 subdomain for most links.
大多数链接的子域。 However I would like it so when someone logs into my site at www.mysite.com and mysite.com, it logs them in in both places on wordpress.
但是,我希望这样做,以便当有人登录到我在www.mysite.com和mysite.com上的网站时,它会将他们登录到wordpress的两个地方。 Among other reasons this is because my wordpress installation is riddled with www and non-www links.
除其他原因外,这是因为我的wordpress安装中充满了www和非www链接。
In PHP this is normally done by leaving the "domain" parameter of setcookie() empty/null or for older browsers, specifying a dot prior to the domain, IE ".mysite.com". 在PHP中,通常可以通过将setcookie()的“ domain”参数保留为空/空来完成,或者对于较旧的浏览器,在IE“ .mysite.com”域之前指定一个点。
Is there any way to get wordpress to perform this behavior? 有什么办法可以让wordpress执行此行为?
You can only have one or the other. 您只能拥有一个。
.htaccess
files in the root of your site. .htaccess
文件之一。 # Redirect www urls to non-www
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]
# Redirect non-www urls to www
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.