I currently have two sites(main site and sub site) created with multisite function. Recently, i noticed that the 404 error page seems not to work on main site. No matter what error url i type to test the error page, it takes me to home page instead of 404 page. But, it is working fine with sub sites. I got no idea how to get this solved.

Here is the htaccess file in my directory:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress 

Before the code above, the code was shown as below(added by the host provider:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

#RewriteEngine on 
#RewriteCond %{HTTP_HOST} ^ncc.my$ 
#RewriteCond %{REQUEST_URI} !^.*www.*$ 
#RewriteRule ^(.*)$ http://www.ncc.my [R=301]

According to the htaccess files above, it should be working fine. Is there any solution to get this solve? Please! Thanks!



define( 'NOBLOGREDIRECT', 'http://www.ncc.my' );
 * WordPress Database Table prefix.
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
$table_prefix  = 'wp_';

 * For developers: WordPress debugging mode.
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
define('WP_DEBUG', false);

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'www.ncc.my');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');
  • Do you have the blogs redirect define set in your wp-config.php?
    – Tom J Nowell
    Mar 10 '15 at 3:16
  • Hi Tom J Nowell, i did nothing to this file at all. But, i'm not sure why it doesn't work.
    – Jornes
    Mar 10 '15 at 3:17
  • You did do something to the file, you have to in order to set up multisite in the first place
    – Tom J Nowell
    Mar 10 '15 at 3:19
  • I set up multisite from one click button in my cpanel. Which means, during the installation, it allows me to choose whether i want to activate the multisite. If yes, i can just tick the selection field.
    – Jornes
    Mar 10 '15 at 3:21
  • Ah then you should look inside your config file to see if that value is set
    – Tom J Nowell
    Mar 10 '15 at 3:22

The cause of your problems is this line:

define( 'NOBLOGREDIRECT', 'http://www.ncc.my' );

If a user visits a blog that doesn't exist, e.g. http://example.ncc.my this is where the user is sent. However there are also sub directory installs, so all requests that aren't found are sent there.

The easy fix would be to set up a page called 404 at ncc.my/404 and then change the define to:

define( 'NOBLOGREDIRECT', 'http://www.ncc.my/404' );

The code fix, which is almost as easy, but gives exactly what you want is to create an MU plugin that removes a filter. To do this, create a file called fix404s.php inside the wp-content/mu-plugins folder ( you may need to create the mu-plugins folder. Inside it, put:

remove_action( 'template_redirect', 'maybe_redirect_404' );

Credit to this blog post for that fix. With that file and those contents in place, your issue should dissapear

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.