Web Dev Blog

Looking for help with WordPress, Apache, Vim, Web Security and more. Here are a few tips.

Category: cPanel

www subdomain causing WordPress multisite redirection loop

WordPress Multisite Redirect from a www Subdomain in Cpanel

One of my clients in my multisite network has been having a reoccurring error.  From time to time the www.foo.com domain would stop working.  foo.com isn’t the primary, so the site would redirect to www.foo.com and fail.  Just a blank page would show.

Of course when a client’s site is down it’s panic mode it can sometimes be difficult to document the fix and then find it again a few months later when the problem reared it’s head.

This time was different, now the problem is solved and I’m documenting the issue.

Reviewing the Apache Logs

I started out seeing this error in my Apache error log

[Wed Apr 16 14:30:31 2014] [error] [client xx.xx.xx.xx] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

This indicated that it was a redirect issue.  .htaccess causes problems sometimes, the next step was to confirm that the .htaccess file matched what was in the Codex


Next step was to look at the Apache logs closer by setting LogLevel debug.  These lines were added to the Apache httpd.conf

RewriteLogLevel 3
RewriteLog "/var/log/apache2/rewrite.log"

(Several comments said this no longer works in newer versions of Apache, but it worked like a champ for me.)
These logs showed more evidence that the problem had to do with the www, but still weren’t helpful enough.  They showed a www directory under the primary domain.  A review showed there was an empty www directory.  This was part of the problem.  Deleting the www directory eliminated the problem, but didn’t explain why it kept coming back.

The httpd.conf directory still showed a VirtualHost listing for foo.com located in a www directory underneath primary.com, but the httpd.conf had warnings not to make edits there.

Back in cPanel, the only listing for foo.com was as a parked domain.  Attempting to delete the parked domain resulted in an error message.  Even stranger.

Finally checked the subdomains.  At some point a subdomain using www for foo.com had been created.  Attempted to delete this subdomain, but again, an error.

Hmm… so can’t remove the parked domain, and can’t remove the subdomain.  Maybe because both existed, back to Google for more searching and finally an answer came up in the cPanel forums.


cPanel won't allow users to create a "www" subdomain - and rightly so, because ww is handled in the main DNS as a CNAME...

However - some of our users have managed this (probably many years ago before the limitation was put in place).

This cause massive problems every apache recompile - because the system thinks the domain's document root is public_html/www

And the reply…

You should check for "www" subdomain entries at the following locations:
Remove entries within the files, and any individual files used purely for the "www" subdomain. Ensure you do not remove the "ServerAlias" itself, as you will still want the "www" alias for the domain name in the Apache configuration.

When you have finished, run the following commands:

Following these steps removed the subdomain from the system and should eliminate the problem permanently.