I am doing a rewrite, in an .htaccess file, to another domain like so:

RewriteEngine On
RewriteRule folder/(.*)  http://newdomain.com/folder/$1

http://newdomain.com/folder is password protected.

I get an authentication popup from newdomain when the rewrite happens. When I enter credentials, it authenticates them against the server doing the rewrite, not newdomain. The browser just hangs, and in my server error logs it continuously writes "user x not found" until I stop the connection.


Which domain is supposed to be doing the authentication? It seems that it should be the new domain, not the old one, given that otherwise one could simply go to the URL with the new domain and access the content without authentication.

In that case, you probably want to rewrite the URL in the user's URL bar, which can be done with the R flag:

RewriteRule folder/(.*) http://newdomain.com/folder/$1 [R]

At that point, everything should be happening on the new domain.

  • There is authentication on both servers which I think may have been the problem. I forgot to add the [P,L] flags, which I was using with the RewriteRule as well. It is working now the way I originally had it. I just changed the htaccess file to point to a different .htpasswd and used Require valid-user instead of Require 'specificUsername'. May have something to do with the new .htpasswd corresponding to one on newdomain... – MF86 Apr 1 '11 at 22:40

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.