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 when开发者_StackOverflow社区ever 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]
Try adding the following to your wp-config.php
define( 'NOBLOGREDIRECT', 'http://domain.com' );
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' );
精彩评论