Page 1 of 1

Rewriting to Zend framework

Posted: Mon Dec 15, 2008 5:22 am
by the_d00d
We're running a shop and currently we have our URL structure like this:

Code: Select all

http://www.example.org/category/item/item-id
We use Zend_Controller_Router_Route_Regex to grab all the requests and pass it to the right controller/action.

All was fine until we wanted to make the category part the subdomain, so we then wanted all requests to look this this:

Code: Select all

http://category.example.org/item/item-id
So, to make this work we have placed the public files into a subdirectory; our structure now looks like:

Code: Select all

/application
   /controllers
   /models
   /views
/library
/public
   .htaccess
   /site
      .htaccess
      index.php
The .htaccess in the public root directory has the following code which rewrites all requests to the site directory (which then the .htaccess kicks in and rewrites requests to the index.php file per usual):

Code: Select all

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.org
RewriteCond %{HTTP_HOST} ([^.]+)\.example\.org(.*)?
RewriteCond %{REQUEST_URI} !^/site/%1/%2$
RewriteRule (.*) /site/%1/%2/ [L]
In the index.php we have changed a few things so that it all works, such as setting the correct include path and setBaseUrl to '/site/'. However, everything seems to go to the index controller and the index action. Any request to, say, clothing.example.org/shirt/123 would not get routed.

Would anyone have an inkling as to why this would happen or what we are doing wrong?
Thanks!