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 ?
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).
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!