Web Dev Blog

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

Category: Multisite

Images Not Uploading From Page – WordPress 4.2

Since updating ot WordPress 4.2 (WP 4.2.1 now), I have had some problems updloading images.

The nice folks over at wpmudev.org helped me out with the problem suggesting that it was probably a javascript problem caused by a plugin conflict.

I did some plugin troubleshooting and determined that this was the case. After more troubleshooting it came down to a conflict between WordPress SEO and Post Thumbnail Editor.

Here is a link to the thread on the WordPress Support forums

JS bug prevents uploading media in Page/Post editor

A temporary workaround is simple enough to get media and image uploads working from the page or post editor.

Just comment out line 171 in post-thumbnail-editor.php and the upload problem will go away.

/** For the "Edit Image" stuff **/
/* Hook into the Edit Image page */
//add_action('dbx_post_advanced', 'pte_edit_form_hook_redirect');

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

https://codex.wordpress.org/htaccess

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.

https://forums.cpanel.net/f34/extra-www-subdomain-cannot-remove-254831.html

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:
/var/cpanel/userdata/username/main
/var/cpanel/userdata/username/sub.maindomain.com
/var/cpanel/users/username
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:
/scripts/rebuildhttpdconf
/scripts/updateuserdomains

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