Problem Redirecting Add-On Domain to Password-Protected Dir

Using a single web hosting account to host multiple sites

Problem Redirecting Add-On Domain to Password-Protected Dir

Postby ginger213 » Sun Mar 09, 2008 4:47 am

Hi,

I hope someone can help with this because I'm going around in circles and I'm thinking I'll probably just have to get a separate hosting account for an add-on domain that requires password protection.

I've used the following rules to redirect non-www access to the www version of my add-on domain:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.my-addon-domain.com$ [NC]
RewriteRule ^(.*)$ http://www.my-addon-domain.com/$1 [L,R=301]

(I've used the same thing in my main domain, with the domain name changed of course.)

In that add-on domain I have a "private" directory where I use the .htaccess file for password protection. The problem I'm having is that when someone accesses the non-www version including the private directory in the url, for example: http://my-addon-domain.com/private/
they get this:

Not Found
The requested URL /401.shtml was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

If they access that url using the www version, there's no problem.

Is anyone able to help?

Thanks for any suggestions.
ginger213
 
Posts: 5
Joined: Sun Mar 09, 2008 4:35 am

Postby richardk » Mon Mar 10, 2008 3:54 pm

What happens if you create 401.shtml?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ginger213 » Tue Mar 11, 2008 2:53 am

Hi,

It just displays the page. I don't get the login prompt.

Thanks,
ginger

p.s. I'm wondering now if this even has anything to do with the fact that it's an add-on domain. Maybe it would do the same thing for a password protected directory in the main domain. (I guess I assumed that because of some other issues I had that pertained to it being an add-on domain.)
ginger213
 
Posts: 5
Joined: Sun Mar 09, 2008 4:35 am

Postby richardk » Thu Mar 13, 2008 12:57 pm

I'm wondering now if this even has anything to do with the fact that it's an add-on domain.

It's probably not. You could create a password protected directory in your main domain's document root.

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule !^private(/.*)?$ http://www.example.com%{REQUEST_URI} [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ginger213 » Fri Mar 14, 2008 5:58 am

Thanks Richard, but I still get a 401 with that code.

Actually, I do have a password protected directory in my main domain's root, and I just checked the redirect on that, and it doesn't work as it should (I hadn't noticed that before.) I don't know if there was always a problem or not because I just moved to a new host. It responds a little differently. If I type in the url for the protected directory (without the www) I get a 404, which I don't understand. This is my rewrite rule for the root:

Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mydomain\.com
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,L]


It looks like I need to read up on Mod_Rewrite and try to figure out where this is all going wrong.

Thanks again, and if you have any other ideas, please let me know.

ginger
ginger213
 
Posts: 5
Joined: Sun Mar 09, 2008 4:35 am

Postby richardk » Sun Mar 16, 2008 10:53 am

On both my 1.3 and 2.2 i get a password prompt when i go to a password protected directory. Is that the only mod_rewrite you have?

You might want to ask your host about it, too.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ginger213 » Tue Mar 18, 2008 6:43 am

Yes, that's the only mod_rewrite I have in my .htaccess file is the one redirecting from the non www to the www url.

Sorry, but when you say 1.3 and 2.2, what are you referring to? Are you typing in the non-www url? Is your redirect from non-www to www?

Thanks

ginger
ginger213
 
Posts: 5
Joined: Sun Mar 09, 2008 4:35 am

Postby richardk » Tue Mar 18, 2008 3:50 pm

when you say 1.3 and 2.2, what are you referring to?

Apache versions 1.3 and 2.2.

Are you typing in the non-www url?

Both.

Is your redirect from non-www to www?

The same mod_rewrite you have.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ginger213 » Tue Mar 18, 2008 5:08 pm

I'm checking with my host now. I'll keep you updated. :-?

ginger
ginger213
 
Posts: 5
Joined: Sun Mar 09, 2008 4:35 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 10 guests

cron