Forum Moderators: phranque

Message Too Old, No Replies

New 301 redirect of non-www to www not working for.......

....password protected folder

         

Clint

3:44 am on Jun 24, 2005 (gmt 0)



Hi all. This is very strange, to me at least. I recently did the 301 redirect for non-www requests to www, and I just realized it's not working for a password protected directory I use for my customers' custom orders! I had in my emails the non-www link for the custom order payments page, and when the link is clicked it goes to my 404 error page! The www must manually be placed in the address bar in order to access the page. So, what's going on here? Evidently this 301 redirect doesn't work for password protected folders, so can someone tell me please how to fix this?
Thanks.

Clint

12:11 pm on Jun 25, 2005 (gmt 0)



Anyone?

Span

2:50 pm on Jul 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Clint, it's strange, yes, definitely. I have password protected folders on three sites at two different servers and 301 redirects from non-www to www and have no problem. Something wrong with your 301 maybe? Does it work for other directories?

jdMorgan

1:39 am on Jul 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I recently did the 301 redirect for non-www requests to www

You might consider posting your new redirect code; Otherwise, we're just guessing...

Jim

Clint

8:03 am on Jul 10, 2005 (gmt 0)



Thanks guys, Jim, I THINK it's one you sent me:

RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST}!^www\.MyDomain\.com
RewriteRule (.*) [MyDomain.com...] [R=301,L]

All other directories are fine, it's just the folder that protected via cPanel's method.

jdMorgan

2:15 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem is probably that mod_auth takes precedence over mod_rewrite. You really need to link to the 'correct' domain in the future.

You might consider adding an exception to your rule set; Do not redirect if the request is for your secure page. Since the search engines can't spider password-protected pages, there's no dupe-content issue anyway.

This can be done with the addition of one more RewriteCond;


RewriteCond %{REQUEST_URI} !^/path_to_secure_page$

It's just a band-aid until you get your links corrected, but avoids forcing the visitor to log-in twice.

Jim

Clint

8:05 am on Jul 11, 2005 (gmt 0)



Jim, I think there's some confusion here. ;) Please see my orig post again. What do you mean by "You really need to link to the 'correct' domain in the future", and and until I get my "links corrected"? I mentioned that I have been sending the www URL to my customers, and I don't know what links I need corrected.

The page is not a "secure" page. It's just a page protected by cPanel's "Password Protect Directories" feature. (Nothing "sensitive" is on the page, it's just so customers will have a little privacy from SE's and the public regarding the details of their "Custom widget order". Then, they click a link on that page and go to a secure page). "Span" above said he doesn't have the problem, so apparently it's something in my 301 direct lines.

Are you saying that I can add this line to my .htaccess file and it will fix the problem?
RewriteCond %{REQUEST_URI}!^/path_to_secure_page$
Thanks.

Span

8:46 am on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Clint, it is nothing in your 301 redirect code.

What is happening is that mod_auth is triggered just before mod_rewrite gets the chance to rewrite your example.com to www.example.com.

So you have to send your customers the www.example.com URL or add Jim's RewriteCond to your 301 code. Adding that line will exclude your secure URL from being rewritten.

jdMorgan

9:27 pm on Jul 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just to clarify, I used the "secure" term sloppily -- I meant the password-protected area.

I had in my emails the non-www link for the custom order payments page, and when the link is clicked it goes to my 404 error page!

These are the links I referred to. In future, send the www link.

For right now, if the non-www link will resolve in the absence of the www redirect, then making an exception to the www redirect should allow your customers to gain access by clicking on the non-www link.

Jim