I have a problem with redirect to protected folder. There are two domains: domain1.com & domain2.com
hosted in two different servers. Both have set in .htaccess rules that adds www to address:
RewriteCond %{HTTP_HOST} ^domain1\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain1.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain2\.com$ [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]
and both have a folder /admin that is protected.
there is no problem when I want to access to this folder in this way:
- http://www.domain1.com/admin
- http://www.domain2.com/admin
but when I try to access them with those addresses:
- http://domain1.com/admin
- http://domain2.com/admin
only domain1.com works properly asking for password,
domain2.com returns 401 ERROR
--------------
--------------
root@vps:~# telnet domain1.com 80
Trying 1.1.1.1...
Connected to domain1.com.
Escape character is '^]'.
HEAD /admin HTTP/1.1
Host: domain1.com
HTTP/1.1 401 Authorization Required
Date: Fri, 29 Jun 2012 18:54:34 GMT
Content-Type: text/html
Connection: keep-alive
WWW-Authenticate: Basic realm="admin"
Accept-Ranges: bytes
Vary: Accept-Encoding
Server: Apache/2
Connection closed by foreign host.
--------------
--------------
root@vps:~# telnet domain2.com 80
Trying 2.2.2.2...
Connected to domain2.com.
Escape character is '^]'.
HEAD /admin HTTP/1.1
Host: domain2.com
HTTP/1.1 301 Moved Permanently
Date: Fri, 29 Jun 2012 18:52:19 GMT
Server: Apache/2
WWW-Authenticate: Basic realm="Panel Administracyjny"
Location: http://www.domain2.com/401.shtml
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1
Connection closed by foreign host.
--------------
--------------
What can be wrong how can it be fixed?
Is it possible that a line with Connection: keep-alive is missed if case of domain2.com? Admin of domain2.com said: it is not possible to make such redirection to protected folder – but you know -.- it is possible as you see with domain1.com — so I have to be sure before saying him what should be fixed.
ok, here is solution: domain1.com has disabled ErrorDocument 401 and that’s why this redirection works – unfortunately it seems that it’s not possible to make such redirection with enabled ErrorDocument 401.