简体   繁体   中英

Wordpress Multisite www non-www Page Redirect Failure

My Wordpress Multisite is setup without the www. I was having an issue whenever I would add the www. ie www.domain.com/post-name/ would redirect me to domain.com.

I soon found out that it was because I removed the /blog/ part of the permalink structure in the super admin section for the site. The redirects were working fine again.

However the pages weren't. So whenever I accessed www.domain.com/page1 it would redirect back to domain.com

Any solution to this?

Remove the define('NOBLOGREDIRECT', 'http://www.domain.com'); from your wp-config file.

Add this in your htaccess file right under RewriteEngine On

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

You don't need to add any codes in htaccess file. There is very easy solution to this. In the 'Network Admin -> Settings -> Domains' page, add both the www. and non-www. versions of the domain, select the box of 'primary' for if you want to mainly use for www. or non-www. and both will be assigned to the website.

尝试将以下内容添加到您的wp-config.php中

define( 'NOBLOGREDIRECT', 'http://domain.com' );

I don't have enough reputation points so I'm posting this as an answer instead of a comment to where I got the solution from.

I added the following code into wp-config.php and while it wasn't used for its intended use, it still worked to solve my 'WP Multisite non-www redirect to www' issue.

define( 'NOBLOGREDIRECT', ' http://example.com ' );

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