• Resolved Override Apps

    (@override-apps)


    When accessing a non-existing path like example.com/random, I get the “Error establishing a database connection” error instead of being forwarded to the themes’ 404 page. How can I fix that?

    My client’s running WP 3.9.1 Multisite (subdirectory) with two sites and a “blank” main-site, installed under /wordpress.

    “Blank”, redirects to /de:
    example.com/wordpress

    German site:
    example.com/wordpress/de

    English site:
    example.com/wordpress/en

    I’m redirecting all traffic from root to the main site, which redirects to the german site in .htaccess: (of course example.com is replaced by the real domain)

    RewriteEngine On
    RewriteBase /wordpress/
    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} ^(www.)?example.com$
    RewriteRule ^(/)?$ wordpress [L]

    My index.php says:

    <?php
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );

    Any suggestions are highly appreciated, thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Override Apps

    (@override-apps)

    I fixed it. Follow these instructions (Using a pre-existing subdirectory install):
    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

    Take your main site to conduct the changes explained there, and use direct DB access to change the “site_url” values of the wp_options and wp_blogs tables to change the URL of your main site to root.

    That will lead any faulty URLs to your main site’s 404 page, which in my case redirects to a subpage. Works out fine for me. Hope this helps anyone.

Viewing 1 replies (of 1 total)

The topic ‘"Error establishing DB connection" when entering random path’ is closed to new replies.