Closed utrenkner closed 8 years ago
Yes, it's possible to run yawik in a subdirectory. Our demo is running in a "subdir" /demo/.
In our demo we are simply setting an alias in the apaches VirtualHost section
Alias /demo "/your/directory/YAWIK/public/"
A change in routing should not be necessary.
Please consider: Running YAWIK (or any other web application) in a subdirectory should always use some sort of aliasing or symlinking the "public"-Directory and keeping the OTHER application resources out of the document root for security reasons.
My problem is: Without Apache, these .htaccess-Rewrites are not executed, obviously
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
But it is these rewrites that seem to influence the basepath() used throughout the viewscripts.
I have configured an h2o-Server so that /mydir/YAWIK/public is accessed via http://mydomain/jobs
But without these rewrites every link in YAWIK is written from the Docroot and I end up with things like http://mydomain/en/jobs instead of http://mydomain/jobs/en
When I explicitly request the index.php http://mydomain/jobs/index.php it correctly redirects to http://mydomain/jobs/index.php/en But I get a 404 (with all links to CSS etc. starting from the Documentroot instead of starting from /jobs ).
Without Apache: Is there any way to influence the behaviour of basebath() to take /jobs into account? How would it work on e.g. nginx?
I have reached the next step - but not fully there yet: I found out that the basepath works like this http://framework.zend.com/manual/current/en/modules/zend.view.helpers.base-path.html
And thanks to AllVince ( https://stackoverflow.com/questions/13955426/zf2-how-can-i-set-basepath-to-be-the-same-for-a-whole-application/13964519#13964519 ), by putting this in the config:
'view_manager' => array(
'base_path' => '/path/'
)
I was able to get it to work, IF I enter the address with the index.php: http://mydomain/jobs/index.php But every further link in YAWIK includes, of course, the index.php in the path... not too beautiful.
Therefore, I still need a fix for the initial redirect from http://mydomain/jobs to http://mydomain/en/jobs As the basepath is fixed only for the view_manager, there must be something else, that triggers the initial redirect and which does not take the new basepath into account.
So, how can I set the basepath for the whole application?
The above mentioned configuration DID NOT after all solve my problem. It actually did not seem to do anything.
A thorough inspection of zend-mvc and zend-http got me on the right track: The path was not correctly set due to this line in php.ini cgi.fix_pathinfo=0
Setting it to cgi.fix_pathinfo=1 solved my problem. No I can access https://mydomain/jobs correctly!
Sorry for all the confusion. Maybe I will find the time to write-up a short how-to for how to install YAWIK on FreeBSD using PHP-FPM and H2O (should work very similary for PHP-FPM and Nginx or with Apache and the event or worker MPM-model)
Hi,
thank you for debugging. We'll take a look, what exact is the problem with the PATH_INFO, when running in CGI Mode.
Please keep in mind security issues, when setting the fix_pathinfo in php.ini.
Regards,
Carsten
As a workaround to not set potential risky php ini values, you can try to set the base path manually in an onBootstrap hook in a Module.php:
public function onBootstrap(\Zend\Mvc\MvcEvent $e)
{
$app = $e->getApplication();
// Load base url from config. (Using a basepath.local.php file in config/autoload e.g.)
$config = $app->getConfiguration();
$baseUrl = $config['baseUrl'];
$e->getRequest()->setBaseUrl($baseUrl);
$basePathHelper = $app->getServiceManager()->get('viewRenderer')->plugin('basePath');
/* @var $basePathHelper \Zend\View\Helper\BasePath */
$basePathHelper->setBasePath($baseUrl);
}
My first tests seem to indicate "no", but then I was not using Apache - I am not sure if the supplied .htaccess file would solve the problem.
My goal would be to have YAWIK run at: https://mydomain/jobs
Is this feasible? Do I have to change the routing in YAWIK?