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]
  • 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. Jun 4, 2012 at 16:42
  • 1
    Why do you need a .htaccess to associate the domains with the directories? That’s wrong, you should do that in httpd-vhosts.conf.
    – fuxia
    Jun 4, 2012 at 16:43
  • Close-voted as off-topic. This is an .htaccess/server configuration question, not a WordPress question. Jun 4, 2012 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, 2012 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, 2012 at 18:34

1 Answer 1


@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]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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