I'm using ZF2 (Zend Framework 2, v2.2) and I would like that http://www.foo.com/path/to/app/ redirect to the public folder.
I've tried a lot of solution but not of them allow the url to point to /path/to/app/public/index.php, while only displaying /path/to/app/.
I would appreciate any solution as I cannot create a virtual host as described in app skeleton README file.
Any help very much appreciated.
Cheers, Greg.
I figured out a solution: https://github.com/gpfister/ZendSkeletonApplication
In short, I added a .htaccess file at the root of the application:
RewriteEngine On
# If URL to the application is http://foo.com/path/to/ZendSkeletonApplication/
# the set the base to /path/to/ZendSkeletonApplication/
RewriteBase /path/to/ZendSkeletonApplication/
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/public/.*$
RewriteRule ^(.*)$ public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ public/index.php [NC,L]
And then I changed module/Application/config/module.config.php.
It is now working fine, though http://foo.com/path/to/ZendSkeletonApplication/public will fail, which is fine as I don't plan to access the app with this URL.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With