WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a shared hosting account with 3 separate domains on it. Each site is in its own directory, so via .htaccess there is a rewrite for each domain name to the corresponding folder.

When I try to log in to WP, the redirect URL that shows up in the address bar has the domain's folder in it.

Ex: www.domain1.com is under folder /domain1

Login redirect after login is http://www.domain1.com/wp-login.php?redirect_to=http%3A%2F%2Fwww.domain1.com%2Fdomain1%2Fwp-admin%2F&reauth=1

So it just brings me back to the login screen with no error message or anything...if I reset the password, however, I can log in successfully. But upon logout I get in the redirect loop again.

EDIT - this code is in .htaccess located in /public_html/. There is also another .htaccess inside /public_html/domain1/ with the standard Wordpress lines.

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(.*)domain1.com$ [NC]
RewriteRule ^(.*)$ /domain1/$1 [L]

RewriteCond %{HTTP_HOST} ^(.*)domain2.com$ [NC]
RewriteRule ^(.*)$ /domain2/$1 [L]

RewriteCond %{HTTP_HOST} ^(.*)domain3.com$ [NC]
RewriteRule ^(.*)$ /domain3/$1 [L]
share|improve this question
If you think it is due to the .htaccess, then it would be a good idea to post your source. There is not that much information, so we can say what exactly is your problem. – Kevin Simper Jun 4 '12 at 16:42
Why do you need a .htaccess to associate the domains with the directories? That’s wrong, you should do that in httpd-vhosts.conf. – toscho Jun 4 '12 at 16:43
Close-voted as off-topic. This is an .htaccess/server configuration question, not a WordPress question. – Chip Bennett Jun 4 '12 at 17:07
@ChipBennett I guess I figured I had to put some WP specific lines in .htaccess. These are existing sites which were working fine before I converted them to WP – javy Jun 4 '12 at 18:33
@toscho there are a few domain aliases which are being pointed to these directories, if that makes a difference – javy Jun 4 '12 at 18:34
up vote 1 down vote accepted

@define('ADMIN_COOKIE_PATH', '/');

Putting this at the top of wp-config.php allows me to log in. Not sure if this is the proper way to set everything up, but it works...


That only solved half of the problem. Permalinks were then broken.

@toscho had the proper suggestion for anyone who may see this and has a similar issue.

However, this hosting provider doesn't allow virtual hosts, so if you're in a similar situation what ended up working for me was a few more .htaccess lines (see below) combined with the wp-config modification above.

# .htaccess main domain to subdirectory redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# 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 these line.

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.php [L]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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