• Resolved kriskrukkert

    (@kriskrukkert)


    Hello,

    I have two WordPress installs: one in the root and one in a subdirectory.

    domain.com
    domain.com/test/

    When I try to acces domain.com it automatically redirects to domain.com/test/.

    Does anyone have any idea on how to solve this??

    Thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • I am assuming that you have two complete sets of WordPress files, one in public_html and another in public_htm/test
    Is this correct ?

    Does the 2nd WordPress site (the one in /test) work ?

    Does each WordPress have its very own database ? the wp-config.php file names the database, please check that the two config files have different databases named. (One possible cause of your problem is that your installations are sharing a database and tables, this will not work).

    If you have two differences databases, then all I can think of is that somehow your WordPress address and/or Site address settings are wrong. These can be fixed by adding these lines to your base “wp-config.php” file:

    define('WP_HOME','http://yourdomain.com');
    define('WP_SITEURL','http://yourdomain.com');

    NOTE that your 2nd website will have ‘http://yourdomain.com/test’ as these two settings, DO NOT change them.

    Please get back here with what you find.

    Thread Starter kriskrukkert

    (@kriskrukkert)

    Yes, I have complete sets of WordPress files, one in public_html and another in public_htm/test.

    They share a database, but have there own database preflix which are defined in config.php

    I checked your solution. The root WordPress now works. Only when I go to the subdirectory WordPress, only the index works. The other pages redirect to the root WordPress.

    Thread Starter kriskrukkert

    (@kriskrukkert)

    I have changed the .htaccess by adding test to the last RewriteRule. This now works for all but one page. Now I’m trying to figure out why this is.

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . test/index.php [L]
    </IfModule>
    # END WordPress

    Well done for figuring out the .htaccess angle.
    I guess it is for this reason that by instinct I never setup WordPress in sub-directories. Instead I use a domain prefix, like:
    http://test.domain.com/

    I configure the sub-domain to use its own directory which is OUTSIDE public_html, (inside is the default but is easily changed).
    This way I have completely independent websites.

    Giving the websites different table prefixes can be a useful variation.

    Which page is not working in the /test website ?

    Thread Starter kriskrukkert

    (@kriskrukkert)

    The page that is not working is the shopping cart. So I’m now digging in the Woocommerce plugin to see what is going wrong.

    If I knew it would be such a hassle putting it in a sub-directory I also would have chosen the domain prefix option.

    My client has hosting with only one DB. Thats why I had to use different table preflixes.

    Thanks for the help!

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘WordPress automatically redirects to subdirectory’ is closed to new replies.