I am trying to install wordpress into a subdirectory of a website.

I simply want to build the client's new site in this subdirectory, so a separate and new WP install in this subdirectory, and then when complete, delete the current (old) site and move the new wp website from the subdirectory to the root.

I've uploaded the wordpress into the subdirectory, I've completed the wp-config file, created my database... and I have double-checked and triple checked that my database name, user and password are the same in my config file as in my database.

Reading the codex it appears I need to change the path in the index.php file, which I've done:

require( dirname( __FILE__ ) . '/subdirectory_name/index.php' 

when I go to the subdirectory to complete the WP install I get the following error message:

Fatal error: require() [function.require]: Failed opening required '/home/user/public_html/subdirectory_name/index.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/user/public_html/subdirectory_name/index.php on line 17

Any suggestions as to what I am doing wrong?

Does it matter that the client's current site is a Joomla site? Help is very much appreciated!


5 Answers 5


To build a separate site in the domainname.com/subdirectory_name directory while leaving the current site live at domainname.com, you would NOT want to modify the index.php file in the root. Your development site address is simply domainname.com/subdirectory_name

  • Thank you. I understand now this is only if moving wp files to another directory while keeping index.php in the root... or that's what I believe. It may be something with my server and I'll have to check.
    – ccbar
    Commented Jul 1, 2014 at 11:49
  • Yes, most of the time issue comes up with server configuration. Otherwise installation is quite simple Commented Jul 2, 2014 at 6:58

Just create a sub directory in your domain root with somename "dev" and put your wordpress files under this directory. Now if your domain name is http://example.com and you have setup under dev directory .

Just hit http://example.com/dev, It will automatically show you install.php to install your wordpress in the current directory.

  • Yes, I created a subdirectory (www.clientsite.com/newsite) and uploaded WP into the subdirectory as I've always done. Navigated to the subdirectory and received an Error. Checked and rechecked my db creditals w that of the config file. After reading codex I change the index.php file path. Now I've changed it back to original and now I navigate to the site and get this message: Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument...
    – ccbar
    Commented Jul 1, 2014 at 11:42
  • All this says to me my database credentials are wrong... but I've checked so many times. I'll check again and report back.
    – ccbar
    Commented Jul 1, 2014 at 11:44
  • Ok fine. Please report back you have got your problem solved Commented Jul 2, 2014 at 6:55
  • @TBIInfotech If I don't want /dev in my URLS do I need to configure that in .htaccess / nginx config?
    – codecowboy
    Commented Jan 12, 2015 at 13:08

I had a similar situation. Have you have checked that in Dashboard>Settings>General Settings Wordpress Address(URL) and Site Address(URL) are the same. That is where my issue was.


Apparently when zipping my wp folder and expanding it through cpanel>file manager, something wasn't working.

If I didn't zip my wp folder and simply uploaded it to the directory, the WP install in the subdirectory worked perfectly.


The best explanation with examples is in WordPress documents Giving WordPress Its Own Directory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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