views:

271

answers:

1

Hey there, this is a newbie Zend question. Under a site location: “mydomain.org/subA/subB”, if we go to this location without logging in (or having a session), it i) redirects to a login page. Otherwise, it ii) redirects to a race registration form. Now, I’d thought that Apache rewrite rules did that, but there’s not config that indicates that in our project .htaccess file:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ /index.php [NC,L]

The only mechanisms I know that can do this sort of rewriting are i) Apache's mod_rewrite or ii) rewriting through Zend's controller or router components. Is there anything else I could be missing? Like I said I'm a PHP/Zend newbie, so it'd be nice to have something that can trace that request to see which systems it passes through.

Thanks

A: 

I would use Zend's built-in routing libraries:

http://framework.zend.com/manual/en/zend.controller.router.html

Zend's router allows you to create re-written routes from within your application, without writing custom mod_rewrite rules. The rewrite rules you pasted from your .htaccess file is what Zend requires to do its job.

EDIT: I read your question a little more closely. I think you understand that Zend has routes. If you're looking for the reason the redirect is working, try checking the controller for the page that needs to authenticate. If preDispatch() is defined in the controller, it may be checking for session authentication and redirecting to a different controller if it's missing.

Bryan M.
I'm confused. Was your question addressing an existing application, or one you were writing? Are you asking how Zend routes work or how to use authentication in the framework?
Bryan M.
Hey there, I've got it working. I was referring to an existing (private) application I am working on, and I'd been through Zend's Controller and Router documentation. It turns out I had to tweak an Zend_Acl object through allow() and deny() methods. It was very tricky as I wasn't expecting a redirect as a kind of post-process decision. Makes sense in retrospect though. Hope that was clear. Thanks for all the feedback.