简体   繁体   English

WordPress多站点非www重定向所有指向首页

[英]WordPress Multisite Non-www Redirects All Point to Home Page

All non-www pages of my WordPress site redirect to the www version of the home page. 我的WordPress网站的所有非www页面都重定向到主页的www版本。 I've tested multiple WordPress themes to rule out my theme and the same issue occurs. 我已经测试了多个WordPress主题以排除我的主题,并且发生相同的问题。 It also occurs on other sites within the multisite installation. 它也发生在多站点安装中的其他站点上。

Here is my WordPress .htaccess file: 这是我的WordPress .htaccess文件:

RewriteEngine On
RewriteBase /

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

# BEGIN NON-WWW REDIRECT TO WWW
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,NC]
# END NON-WWW REDIRECT TO WWW

The site is WordPress 4. I thought WordPress itself should automatically do the non-www redirect out of the box if it has the domain setup. 该站点是WordPress4。我认为WordPress本身应该自动进行非www重定向,如果它具有域设置。 Do you have ideas as to what is causing the issue or ways to diagnose? 您是否对导致问题的原因或诊断方法有任何想法?

This works for me: 这对我有用:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM