SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Redirection & password protection

    Hello.

    I've got some problems with .htaccess

    In the root folder of my site, I've got

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^toto.net
    RewriteRule (.*) http://www.toto.net/$1 [R=301,L]
    so that toto.net is redirected to www.toto.net. Ok, it's working.

    Now I've got a subfolder called 'test' with this .htaccess

    Code:
    AuthUserFile /homez.110/toto/www/test/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Accès Restreint"
    AuthType Basic
    <Limit GET POST>
      require valid-user
    </Limit>
    so that www.toto.net/test is asking me a username and a password. It's also working.

    But ... if i use toto.net/net, it asks me the user/password. Ok. Then redirect to www.toto.net/test. Ok. But then ask me a second time the user/password. It seems to be logic but is not what i want. How to avoid the system asking me the second identification ?

    Thanks.

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by tweetysat View Post
    Hello.

    I've got some problems with .htaccess

    In the root folder of my site, I've got

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^toto.net
    RewriteRule (.*) http://www.toto.net/$1 [R=301,L]
    so that toto.net is redirected to www.toto.net. Ok, it's working.

    Now I've got a subfolder called 'test' with this .htaccess

    Code:
    AuthUserFile /homez.110/toto/www/test/.htpasswd
    AuthGroupFile /dev/null
    AuthName "Accès Restreint"
    AuthType Basic
    <Limit GET POST>
      require valid-user
    </Limit>
    so that www.toto.net/test is asking me a username and a password. It's also working.

    But ... if i use toto.net/net, it asks me the user/password. Ok.
    WAIT! THAT's NOT OKAY with what you've shown! Obviously, the problem is that you're not showing everything.
    Then redirect to www.toto.net/test. Ok. But then ask me a second time the user/password. It seems to be logic but is not what i want. How to avoid the system asking me the second identification ?

    Thanks.
    Please show ALL your .htaccess in the DocumentRoot, net directory and test directory as there is something missing in what you've shown.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I don't understand what you think is missing.
    In the root, just 4 lines but I don't think there is a link with the problem

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^toto.net
    RewriteRule (.*) http://www.toto.net/$1 [R=301,L]
    
    SetEnv PHP_VER 5
    SetEnv REGISTER_GLOBALS 0
    Options -Indexes
    DirectoryIndex index.html index.php

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    tweety,
    Quote Originally Posted by tweetysat
    But ... if i use toto.net/net, it asks me the user/password. Ok.
    With what you've shown in your first post, that is not possible. Your second post does not show anything that would indicate that there is password protection on the net subdirectory. Was that a typo? Should it have been toto.net/test? If it was, then I'd say that the Apache core is asking for the password before mod_rewrite gets to redirect - and there's nothing you can do about Apache's ordering of its internal processes (except to use the correct link, of course).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I've understood. You're right.
    I wrote toto.net/net in place of toto.net/test !!

    So for you there is no solution ? What do you mean with "except to use the correct link, of course" ?

    Thanks.

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    tweety,

    No problem! You sure had me fooled, though!

    Okay, for your problem:

    1. How is your toto.net/test directory linked? Do you provide a link in your website or is it a matter that someone has to type the link in their browser?

    IMHO, it's a poor technique to force typing so you should be providing a link - even if you hide the link by only displaying it to a specific login which can be maintained by $_SESSION data. Therefore, if you're providing a link, provide the www'd link, not the no-www link. Hey, an internal link will do that for you, anyway, as you're forcing www on the entire website! Then, you won't have to worry about a non-www link and the problem evaporates into thin air ... like magic!

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  7. #7
    SitePoint Member
    Join Date
    Sep 2010
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, thanks.

    I will use it with a link (and www. )


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •