Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.