homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

Wordpress on Domain AND Subdomain
2 unrelated blogs on one domain

 3:08 pm on Dec 4, 2012 (gmt 0)

I have a working, functioning WP blog at www.domain.com. Last night I tried to install a new WP blog at sub.domain.com, and the exercise failed miserably.

The sub installation took over the existing, and it was a bear getting things back to the way they were.

The purpose of this post is to figure out where I went wrong - any assistance is definitely appreciated.

Here's what I did:

1) Add subdomain in plesk with a new FTP user specific for that sub
2) Create a database named sub_wp - unrelated to existing db
3) Create a db user for that database
4) Adjust wp-config as per the instructions
5) go through the WP 5 minute install

When I got to the last instruction in the install where you go to sub.domain.com/wp-admin/install.php, that's when things got a little haywire. I got an error that there was already a WP installation - various tips online mentioned changing the database table prefix in the wp-config file - I did that, and the new blog took over the old one.

Any tips on how to set this up correctly?



 3:14 pm on Dec 4, 2012 (gmt 0)

If you're trying to setup a WP Network, you don't need to add the sub-domain using anything but WP's Network Admin. Nor do you need to setup a new db. WP takes care of all of that for you.

See: [codex.wordpress.org...]


 3:18 pm on Dec 4, 2012 (gmt 0)

Not a network at all. Installs/sites are totally unrelated.

My client has an existing install at domain2.com, and have hired me to work on it. Rather than redesign the live site, I'd like to build them a new staging site at sub.domain.com to preview changes, etc.


 3:23 pm on Dec 4, 2012 (gmt 0)

Okay - if you're doing a completely separate install, make sure it's in a directory at the same level as the main and NOT in a sub-directory of the main installation.


 3:41 pm on Dec 4, 2012 (gmt 0)

That's what I did Lorax - existing install was at domain.com/ - new install was at sub.domain.com - different DB's specified in each wp-config, different db users, etc.


 4:02 pm on Dec 4, 2012 (gmt 0)

And you're sure the physical files are in a completely separate directory? I ask only because it's acting like htaccess for one is affecting the other. And if you did create two separte installs then there should be no changes to the wp-config.php files other than is necessary for a single install to work (eg - no MultiSite)


 4:44 pm on Dec 4, 2012 (gmt 0)

Aha! .htaccess is the answer -

domain.com was set up as multisite about 6 months ago, and I didn't really like working that way, so I removed the wp-config modifications that make that happen.

What I did NOT do was to fix the htaccess part - so this stuff is in my htaccess on domain.com:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]

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

# END WordPress

Not sure what all this means. What should I remove/change to make this subdomain thing work?


 1:44 am on Dec 5, 2012 (gmt 0)

Okay - if you're doing a completely separate install, make sure it's in a directory at the same level as the main and NOT in a sub-directory of the main installation.

I don't follow. The "same level" would be another subdomain, e.g. blog.example.com?

If the main WP site is at www.example.com then I have plenty of live examples of a second WP install at www.example.com/blog. This happens where the main site is built with pages, i.e. not as a blog, but the template for that site uses posts for something else, e.g. elements on a slider. I also have come across a situation where the additional WP installs are needed to keep users separate, to keep plugins separate, different theme, etc


 4:11 pm on Dec 5, 2012 (gmt 0)

@mrblond: I've done the following to help resolve issues similar to yours. Keep a copy of that htaccess file somewhere safe then delete it from the webserver. Login to the admin panel and go to Permalinks. Make sure they are setup the way you want them then save the permalink structure (even if you don't make changes). This will recreate the htaccess file - hopefully as it should be to work with the current install (eg no legacy code from the multi-site config).

The "same level" would be another subdomain, e.g. blog.example.com?

WP installs use HTAccess files to control URLs, redirects, etc - but unless you use the Network option, they are completely unaware of each other so placing two installs under the same directory structure lends itself to certain abuses/trouble like redirects. It's not impossible to do this - it's just easier to manage and avoid issues by separating them into completely separate directories.


 4:36 pm on Dec 5, 2012 (gmt 0)

Excellent - thanks for the help Lorax.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved