Go up one directory in mod_rewrite

Posted by Rudolph Gottesheim on Pro Webmasters See other posts from Pro Webmasters or by Rudolph Gottesheim
Published on 2013-06-26T14:11:15Z Indexed on 2013/06/26 16:30 UTC
Read the original article Hit count: 232

Filed under:
|

I've got a standard Zend Framework 1 project that looks a bit like this:

Project
|- public
 |- .htaccess
 |- index.php

The .htaccess looks like this:

RewriteEngine On
RewriteBase /
RewriteRule ^image/.*$ img.php?file=$1 [NC,L]
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Now I want to start transitioning the site to Zend Framework 2, which I put in a separate directory in the root, so the whole thing looks like this:

Project
|- public
 |- .htaccess
 |- index.php
|- zf2
 |- public
  |- .htaccess
  |- index.php

What would I have to change in my original (ZF1) .htaccess to route all requests to (for example) /zf2/whatever to ZF2's index.php? I've tried RewriteRule ^zf2(/.*)$ ../zf2/public/index.php [NC,L] in the line after RewriteBase /, but that just gives me a 400 Bad Request.

© Pro Webmasters or respective owner

Related posts about apache

Related posts about mod-rewrite