■■■■, was hoping you’d solved.
I’ve come up with a rather messy behind the scenes solution, from a user point of view they notice nothing. Unfortunately looks as though on the WD it won’t read anything in the .htaccess file.
Previously I had my external server acting as a reverse proxy, so rather than having (example URL) server.domain.com:1111/cops, I had books.domain.com (no port, no subdirectory), done by having my external server with .htaccess file. I wanted to keep this reverse proxy AND add htpasswd protection, however as the reverse proxy is done via .htaccess and so is .htpasswd, they wouldn’t work together, as the reverse proxy would bypass the authentication and just show the COPS environment.
So the solution I’d had to come up with is;
-
books.domain.com has .htaccess setup with htpasswd to protect, authorised network IP’s come through without need to authenticate, if accessing from outside one of my networks (ie on mobile connection), users must authenticate.
Once authenticated either by IP or username/password, user is directed to an index file which auto redirects to a subdirectory /books which has a second .htaccess file with the reverse proxy, which masks the full URL, so the user only sees the cleaner short URL.
They are now in COPS with the URL of books.domain.com/books.
So while this all works perfectly, next issue is the fact if someone just entered books.domain.com/books they’d bypass the root books.domain.com which is where it authenticates them, so if a user shared a direct link with someone, they’d skip the authentication.
To resolve this, have added a script to the index.php of the COPS environment that only accepts users with a valid referral from books.domain.com if they have a referral, they’ll continue, if they have no referral (ie they accessed the link directly), it’ll push them back to books.domain.com to complete the authentication.
So while this is all working, I really wish I could’ve just been able to use the .htaccess in the COPS directly on my WD PR2100, then could’ve avoided all the extra config.