Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

|- 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:

|- 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.

share|improve this question

You need mod_alias, not mod_rewrite:

Alias /zf2/ ../zf2/public

Maybe you'll need to specify absolute path instead of relative.

Another solution would be use of a filesystem symbolic link named zf2, placed in Project/public and pointing to ../zf2/public.

In both cases you'll need Options +FollowSymlinks. And be careful about restrictions and where they apply to.

See Accessing files outside the document root with Apache on StackOverflow.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.