My WordPress Multisite is setup without the www. I was having an issue whenever I would add the www. i.e. 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
Try adding the following to your wp-config.php
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.
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‘ );