Forum Moderators: phranque
It's simple enough for php pages in the membership area to redirect users who aren't logged in to another page. We also have content that isn't php pages, such as movies. I've been looking at mod_rewrite, but I haven't been able to come up with a solution.
I'm guessing there are standard design patterns for handling this problem, but haven't been able to find anything in my searches on the web. Any suggestions?
Thanks.
Welcome to WebmasterWorld [webmasterworld.com]!
The only thing that comes to mind here is to use cookies, which can be interrogated by mod_rewrite. If you can define "a member" in terms of how that is defined by your system, that would be helpful in getting better replies.
Jim
It's a public site, and people pay a fee to become a member. We have pages that allow users to create a name and password when they sign-up, and that name and password is stored in a MySQL database. Anyone accessing the site should be able to see all the content in the /free directory. Members will login to the site and we'll validate the name and password they supply. If they're a valid member, then they should be allowed access to the content in the /members directory.
From what I've been able to read it sounds like some form of http authication comes pretty close, since it allows you to secure entire directories. We'll have 1000's of members, so I'm guessing I'll need to use a database for the username and passwords.
The downside of http authtication is that the browser supplies the dialog that prompts for user name and password, and I'd prefer to use a form on a page in my site.
The only part of this that is well-suited to Apache functions is the URL rewrite. Try a search on WebmasterWorld for "static dynamic URL rewriterule" for examples. The major piece of work here is in the authentication scripting.
Jim
As you suggested, I've been playing with mod_rewrite and cookies and that's working for me.
There may be a few more things I'll need to tighten up, but cookies and mod_rewrite has gotten me past my major hurdle. I'll also check for "static dynamic URL rewriterule" in this forum and see if that turns up any other ideas I want to consider.