简体   繁体   中英

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. I've tested multiple WordPress themes to rule out my theme and the same issue occurs. It also occurs on other sites within the multisite installation.

Here is my WordPress .htaccess file:

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. 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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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