Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Apr 3 '11 at 22:04

This question came from our site for professional and enthusiast programmers.

1 Answer 1

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.

share|improve this answer
    
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

 
discard

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.