• Resolved Knordelia

    (@knordelia)


    Hi,

    I want to setup a new wordpress site (done 2 before) and I’ve stumbled across point 7 in this wordpress guide regarding the issue with an own directory. There it says that I should copy “the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address).

    Question 1: Why do I need to do that?

    Until now I used to just create an own directory and copied wordpress there without doing anything in the root directory and it worked.

    Question 2: What if I have the following situation:

    I have a domain/webspace

    abc.com

    which apparently is also my root folder. In this root folder I could also have a wordpress installation (for a different site). My new page would be under the domain

    xyz.com

    in its own folder e. g.

    abc.com/root/xyz

    . If I then would copy from the index.php and .htaccess from xyz to abc I would corrupt my abc website or make an usage of it impossible, or wouldn’t I?!

    I’m rather new to this and no coder, so I would really appreciate it to get some help or hints here. Thanks!

    P.S.: I’ve also asked this as part of a more another more complex question which unfortunately never got any reply.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Not everything mentioned in the things you are reading needs to be done in every situation, and neither do the things you are reading address-and-cover every situation. For example, I have Add-On Domains and even a WordPress sub-domain in nested folders and I have *never* had to edit index.php in order for any of those to work.

    If you wish, I will try to help you here and even in your previous thread.

    How many registered domain names do you have, and where do you want each to land?

    Thread Starter Knordelia

    (@knordelia)

    Thanks for your reply.

    This is what I was also wondering..I never did anything to the index.php before and having every website nicely in its own folder in root (of a main domain) has so far worked (until I tried this thing with the URL change as explained here, which I got resolved by writing the 2 urls (WP and site) into the wp-config.php).

    Actually I’m using two hosting providers. One offers the option to create a sub-account where the separation is clearer. In the other one you can do the “normal” (?!) stuff, having a root folder which is actually also a domain and could be used for a website and in that root folder I have currently one subfolder containing the content for site

    xyz.com

    [this one I can also access by using the name of the site’s folder in front of the main/root domain abc.com(=

    xyz.abc.com

    )].

    My main concern right now is whether the index.php and .htaccess (or any other file) in the root folder (=for the main domain

    abc.com

    ) can somehow interfere with a subfolder (located in the root folder:

    xyz.com

    in its own folder xyz)? Right now when I don’t use the main domain

    abc.com

    and only the one which is located in the subfolder it works fine, but when I start to use the main domain and put a wp installation into the root folder which can be accessed via

    abc.com

    what will happen? The easiest solution would be to redirect

    abc.com

    to an own subfolder in the root (basically the main domain

    abc.com

    ), but this does apparently not work!?

    I guess this is something basic and simple, but I’m currently totally confused with this. ??

    Actually I’m using two hosting providers.

    Which one would you like to talk about first, and what configuration of folders do you actually have? For example, here is mine:

    www.domain1.net	@ /home/serveraccount/public_html/.htaccess & index.html
    www.domain2.net	@ /home/serveraccount/public_html/domain2/.htaccess & index.php (WordPress)
    www.domain3.net	@ /home/serveraccount/public_html/domain3/.htaccess & index.php (WordPress)
    www.domain4.net	@ /home/serveraccount/public_html/domain3/domain4/.htaccess & index.php (WordPress)

    Thread Starter Knordelia

    (@knordelia)

    The one (provider) that raised the question regarding index.php and .htaccess has basically the same structure as you mentioned.

    So now it is as follows:

    www.domain1.com [main domain] @ /home/account/public_html/.htaccess & index.php -->This domain is not in use yet, so there is no website
    www.domain2.com @ /home/account/public_html/domain2folder/.htaccess & index.php --> In use with WP website. To make it work I had to create a subdomain for it, so it can also be reached via "domain2.domain1.com"

    Now I’m asking myself if there can be some interference when I start to use domain1.com which could only work by using the root folder. That’s actually my main question.

    I’m also planning to create another website domain3.com in this folder:
    www.domain3.com @ /home/account/public_html/domain3folder/.htaccess & index.php --> For my understanding this shouldn't be a problem

    Thanks.

    It looks to me like you have things straight.

    https://www.domain1.com @ /home/account/public_html/.htaccess & index.php
    –> This domain is not in use yet, so there is no website.

    When the time comes and if you would like to have that domain in its own sub-folder alongside the others in public_html to help keep all of your installations separate-and-orderly, there is where this should work in /public_html/.htaccess:

    # BlueHost.com
    # .htaccess main domain to subdirectory redirect
    # Do not change this line.
    RewriteEngine on
    # Change example.com to be your main domain.
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    # Change 'subdirectory' to be the directory you will use for your main domain.
    RewriteCond %{REQUEST_URI} !^/subdirectory/
    # Don't change the following two lines.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Change 'subdirectory' to be the directory you will use for your main domain.
    RewriteRule ^(.*)$ /subdirectory/$1
    # Change example.com to be your main domain again.
    # Change 'subdirectory' to be the directory you will use for your main domain
    # followed by / then the main file for your site, index.php, index.html, etc.
    RewriteCond %{HTTP_HOST} ^(www.)?example.com$
    #RewriteRule ^(/)?$ subdirectory/index.html [L]
    # Use index.php for WordPress
    RewriteRule ^(/)?$ subdirectory/index.php [L]

    At that point, https://www.domain1.com will land at that sub-folder and you will not have to modify anything in WordPress.

    https://www.domain2.com @ /home/account/public_html/domain2folder/.htaccess & index.php
    –> In use with WP website. To make it work I had to create a subdomain for it,
    so it can also be reached via “domain2.domain1.com”

    At BlueHost, cPanel sets all of that up automatically and displays this note when an Add-On Domain is assigned to a directory:

    Sub-domain: domain2-com.domain1.com
    
    This subdomain is required for cPanel. You will still be able to access your domain name directly by going to domain2.com.

    Now I’m asking myself if there can be some interference when I start to use domain1.com
    which could only work by using the root folder. That’s actually my main question.

    Not in my own experience. I have several domains known to cPanel as subdomains of .domain1.com and each works completely independently of any other. At the same time, however, I have a stand-alone firewall installed at public_html that checks *all* traffic going to *any* domain.

    Also, and depending upon how your host handles PHP, it might be possible for you to use a single php.ini file in public_html to control PHP for all domains at once.

    Thread Starter Knordelia

    (@knordelia)

    Thanks leejosepho for your help and time. I appreciate it very much!

    Gotta to bookmark this page for the future. It could be pretty soon when I start to use domain1.com.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Copy of index.php and htaccess in root folder necessary?’ is closed to new replies.