Forum Moderators: phranque

Message Too Old, No Replies

Htaccess question (again)

         

stubbsy

5:35 pm on Oct 9, 2005 (gmt 0)

10+ Year Member



hi there,

you recently helped me out with a problem which i had in this thread [webmasterworld.com...] Where i wanted to redirect all traffic to another site vai a 301 except to allow me access to the admin folder on that site.

What I would like to do is add password protection to the admin folder that I wanted access to.

What I have found is that if I create a htaccess file in this folder then I get a 404 when trying to access it.

The code I have in the htaccess in the root of the site is

Options All -Indexes 
#
RewriteEngine On
#
RewriteCond %{REQUEST_URI}!^/admin/
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

and all works fine until I put a htaccess file in the admin folder when I get the 404. If I delete this file then all works ok, but the admin is unprotected.

The code in the htaccess in the admin folder is

AuthType Basic

AuthName "Restricted Area"

AuthUserFile "/home/mysite/.htpasswds/example/admin/passwd"

require valid-user

Any ideas?

Thanks

stubbsy

jd01

5:55 pm on Oct 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will probably need to add the rules from the root .htaccess file to the directory you are working in, or use the 'inherit' option.

In the second .htaccess:
RewriteEngine on
RewriteOptions inherit

OR

Adjust the rule you need to work in the directory you are working in, and add it to the lower level .htaccess

EG if you have this in the root and your directory is called 'yourdirectory'
RewriteRule ^yourdirectory/youpage\.ext$ /do/something.ext [L]

You would use this in the lower level:
RewriteRule ^youpage\.ext$ /do/something.ext [L]

Hope this helps.

Justin

stubbsy

7:02 pm on Oct 9, 2005 (gmt 0)

10+ Year Member



Hi jd01

thanks for the quick reply. I've tried the options you have given but still get a 404 when trying to access the admin folder when I have the htaccess in that folder requesting the password.

If i remove the code requesting the password then I can access the folder.

thanks

stubbsy

jd01

7:43 pm on Oct 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure on this, might need to wait for someone with more password protection experience than I have -- don't normally answer questions RE passwords, because I do not work with them enough to know what exactly is happening...

Wish I could be more help, but will defer to someone with better knowledge of how the two interact.

Justin

stubbsy

8:09 pm on Oct 9, 2005 (gmt 0)

10+ Year Member



Thanks for trying, I appreciate your help.

stubbsy