Al Foиce    ѫ Al Foиce ѫ - 1 year ago 83
PHP Question

Rewrite rule for a zf2 app in a subfolder

I have a domain with several applications, URLS are :

app3 is a zf2 application, so my root tree is something like :


I do not want to use subdomains for the zf2 app.

But the app3 root URL must redirect to the public subfolder, as it is a zf2 app. So in /app3/ I wrote an htaccess file to redirect to public folder :

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/app3/public
RewriteRule (.*) /app3/public/$1 [L]

But My app3 (url always displays 404 error, saying route don't exists. The URL helpers in my layout makes urls likes instead of

So I guess there is a route issue : how to say this zf2 application that it is located in a subfolder /app3/ ? Remember, I don't want to use subdmains... Is there something I can do in my .htaccess, or in my zf2 application ?

Answer Source

I didn't found any simple solution to locate a ZF2 app in a subfolder without using subdomains or hacking the route system.

The easiest way is to run ZF2 as root application.

And if other applications are not designed to run in subfolders, user subdomains. For information, this is what I've done :        => is now a part of /app4/   => no change,       /app1/   => no change,       /app2/   => ZF2 app is now   /      => merged with my root pages. I added an app3 route to keep the old urls compatibles with the new app...   => no change,       /app4/
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download