Reputation: 31
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?
Upvotes: 3
Views: 6393
Reputation: 11
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.
Upvotes: 1
Reputation: 15
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' );
Upvotes: 0
Reputation: 1597
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]
Upvotes: 5
Reputation: 369
Try adding the following to your wp-config.php
define( 'NOBLOGREDIRECT', 'http://domain.com' );
Upvotes: 2