Stop subdomain redirects to main domain in wordpress

I have a website that is build in WordPress.

I want to build the sub-domains for the site according to the states same as “olx.in” do for different cities.

Read More

Everything is setup from the code, server and hosting side, but the problem I am facing is that when I type any sub-domain in the URL like “rj.mysite.com” then I there is somewhere somthing written in the wordpress php file, that is redirecting me to the main domain because I made many changes in the .htaccess file but nothing worked out.

I have tried so much but couldn’t found the script that is redirecting the sub-domains to the main domain.

Can anybody please tell me that what should be there in the php code of WordPress that is redirecting my sub-domains to the main site?

Related posts

Leave a Reply

2 comments

  1. just found the answer today, hope you’ve solved it, assuming you have,
    what i did for mine was create another wp-config.php file, named it wp-config-sub.php, then in your sub domain, require the wp-config-sub.php file, instead of the wp-config.php file,

        require_once '../wp-config-sub.php';
    

    then go back to your wp-config-sub.php file and comment out these lines

    /* Multisite */
    //define( 'WP_ALLOW_MULTISITE', true );
    //define('MULTISITE', true);
    //define('SUBDOMAIN_INSTALL', false);
    //define('DOMAIN_CURRENT_SITE', 'yoursiteprimaryurl.com');
    //define('PATH_CURRENT_SITE', '/');
    //define('SITE_ID_CURRENT_SITE', 1);
    //define('BLOG_ID_CURRENT_SITE', 1);
    

    hope this will solve your problem. 🙂

  2. if everything correct in the NS records and the domain redirects
    I think you need to login to wordpress and change in the general settings

    WordPress Address (URL)
    and
    Site Address (URL)

    to your sub domain or to check your .htaccess file