Page 1 of 1

Zend Framework's Rewrite Router

Posted: Fri Dec 08, 2006 1:25 pm
by Luke
I am using the Zend Framework's Rewrite router, but I'm having a hard time getting it to work. I am trying to rewrite a url from http://www.mysite.com/Event_Calendar/De ... index.html to a url like this:
http://www.mysite.com/calendar/view/December/2006

Maybe somebody can spot where I'm going wrong. This is my .htaccess file (seems to be working how it should):

Code: Select all

RewriteEngine on

RewriteEngine on
RewriteRule !\.(js|ico|gif|jpg|png|css)$ /calendar/index.php
And in my bootstrap file I have the rewrite router set up like this:

Code: Select all

$router = new Zend_Controller_RewriteRouter();
$router->addRoute(
	'view',
	new Zend_Controller_Router_Route(
		'/Event_Calendar/:month_:year/index.html',
		array('controller' => 'events', 'action' => 'view', 'year' => date('Y', time())),
		array('month')
	)
);
As far as I know that should work... but it doesn't. When I go to the url, I just get taken to /calendar/index.php every time with no extra


EDIT: I've also tried this configuration with no success:

parameters being sent... why?

Code: Select all

RewriteEngine on

RewriteCond %{REQUEST_URI} /Event_Calendar/([a-zA-Z]*)_([0-9]*) [NC]
RewriteRule ^([a-zA-Z]*)_([0-9]*)/index.html /calendar/view/$1/$2 [L]

RewriteCond %{REQUEST_URI} (/Event_Calendar/index.html|/Event_Calendar) [NC]
RewriteRule (.*) /calendar/index.php [L]
and in the bootstrap...

Code: Select all

$router = new Zend_Controller_RewriteRouter();
$router->addRoute(
	'view',
	new Zend_Controller_Router_Route(
		'/calendar/view/:month/:year',
		array('controller' => 'event', 'action' => 'view', 'year' => date('Y', time())),
		array('month')
	)
);