When I access my domain:
www.example.com without the www. the site will automatically loop the site url multiple times in the browser bar.

In browser bar before hitting enter:

example.com

After hitting enter:

www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/

This works fine:

www.example.com

I’ve set up a wordpress multisite network with 3 domains.

I have this code in the wp-config.php file

define('WP_ALLOW_MULTISITE', true);
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'www.example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

define('NOBLOGREDIRECT', 'www.example.com/');

/* had to set this because it redirected to the login page every time */
define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', ''); 

My .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[0-9a-zA-Z-]+.[a-zA-Z]{2,}$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^index.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]
# END WordPress

I’ve put highlighted line of code in the .htaccess file to
– force every access to go to the https version of the website

– but won’t redirect when accessing a specific subdomain:

With this, I got rid of the www. error but the error persists when I set something behind the slash for example:

In browser bar before hitting enter:

example.com/abc

After hitting enter:

www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/www.example.com/

This works fine:

www.example.com/abc

Anything from one character to a word everything causes the looping domain error…

Edit:
Changing these two lines in the wp-config.php to:

define('DOMAIN_CURRENT_SITE', 'example.com');
define('NOBLOGREDIRECT', 'example.com');

Will place the domain exactly 2 times in the browser bar, so it looks like this:

In browser bar before hitting enter:

example.com/abc

After hitting enter:

www.example.com/www.example.com/

Read more here: Accessing wordpress multisite without www. sets the site url multiple times in browser bar


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: