2

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.

1 Answer 1

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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