Reputation: 18451
I want to install my ZF2 application on a VPS server without support for Virtual Host. I´m using a simple application based on ZendApplicationSkeleton.
I´m using the default .htaccess
:
RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size
# fits all solution.
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
All solution I´ve found in SO does not work for me. They may fit ZF1, but not ZF2:
My application is in a folder named /var/www/html/testapp
.
The main page is loaded once I typelocalhost/testapp/public
on the browser. Also my module is loaded if I type localhost/testapp/module
, but navigation does not work.
Ie: in the main page, I´ve created a button like:
<a href="/module/index">Go To Module</a>
But if I click on it I navigate to localhost/login/index
showing Not Found
, not to the correct module/index.phtml
page.
Help appreciated with that.
Upvotes: 0
Views: 57
Reputation: 33148
Your problem has nothing to do with server configuration. Since your app is in a sub-folder, the link is wrong. It would need to be something like
<a href="/testapp/public/module/index">Go To Module</a>
for it to work. However, public/
should never appear in you URLs. With things setup this way you are allowing users to view files outside your app's web root, which is a potential security risk (and results in ugly URLs).
The solution to this is to setup a separate vhost for your ZF2 app, which has a DOCUMENT ROOT pointing at the app's public folder. If you are having problems with this, post that as your question; or if you can explain why this isn't possible perhaps we can advise further.
Upvotes: 1