I'm on shared hosting where www only accessible by web server , so I change the structure recommended for the project based ZenFramework putting the library under the folder www :
www/
index.php
application/
Modules/
front/
admin/
Library/
the .htaccess :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I tested locally under WampServer, everything works fine.
when I go online, I get errors on View Helpers :
Warning: include_once(): Unable to access /home/www/application/Modules/front/views/helpers/HeadMeta.php
there is confusion between ZendFramework views helpers and the view helpers that I create myself. and when I copy the content :
library \ Zend \ View \ Helper \
to
\ application \ modules \ front \ views \ helpers
everything works fine ! and it is the same concern for module admin/
I do not understand how why.
is what I have to keep the View helpers with my aides custom view ?
Thank you in advance for your answers.
Update:
I have not attached and any help create by myself . but I have to create action helpers, like this:
resources.frontController.moduleDirectory = APPLICATION_PATH "/Modules"
resources.frontController.defaultModule ="front"
resources.frontController.actionHelperPaths.Application_front_Controller_Helper = APPLICATION_PATH "/Modules/front/controllers/helpers/"
resources.modules[]=
Bootstrap module :
class front_Bootstrap extends Zend_Application_Module_Bootstrap
{
public function _initHelper()
{
$this->bootstrap('frontController');
$navigation = Zend_Controller_Action_HelperBroker::getStaticHelper('NavigationPath');
Zend_Controller_Action_HelperBroker::addHelper($navigation);
}
}
Several thoughts/questions/comments:
It sure seems to be looking for the view helper within your Module folder. Are you attempting to call a custom HeadMeta helper developed by you, or are you are attempting to call the standard Zend_View_Helper_HeadMeta helper? Have you set any helper paths in either Bootstrap or application/config.ini?
Your current setup has a security issue: What if someone requests the url: http://exmaple.com/application/config.ini? I don't see any protection there. Note that you don't necessarily have to move all your ZF folders up in to the document root. Rather, you could push them down and place deny-all protection on that folder. See: Zend Framework on shared hosting. That blog post offers other approaches to ZF on shared hosting, as well.
Finally, when something works on Windows but doesn't work on Linux, there are several usual suspects to check.
Related
I am working on a Rest Api for my application. This is my application structure
api
-config
-modules
--v1
---controllers
---models
-runtime
-tests
-web
backend
common
console
environments
frontend
I tried runing the following url http://192.168.1.4/~user/urshow/api/modules/v1/web/users
I got a Not found Error. I do have a controller named Users inside controllers folder.
My .htaccess file is like this (which is inside urshow/api/web)
RewriteEngine on
RewriteBase /~user/urshow/api/modules/v1/web/
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
I found the solution. I had made some mistakes. First my .htaccess file was incorrect.
i had this line before RewriteBase /~user/urshow/api/modules/web/
i changed it to RewriteBase /~user/urshow/api/web/
also the url which i was trying was also wrong http://192.168.1.4/~user/urshow/api/web/movies/details
correct url is http://192.168.1.4/~user/urshow/api/web/v1/movies/details.
You haven't added the rest of the url to the redirect. Try using this on your last line;
RewriteRule ^(.*)$ index.php$1
Im having problems deploying my Laravel 5 Project on Go Daddy Plesk . I'm getting Internal 500 Error. Here's the folder structure.
/Root Directory
/app
/boostrap
/config
/database
/storage
/resources
/vendor
/httpdocs
index.php
/css
/js
Then my server.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylorotwell#gmail.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/httpdocs'.$uri))
{
return false;
}
require_once __DIR__.'/httpdocs/index.php';
So as you can see, I deleted my public folder in my laravel and transfered all the public contents inside httpdocs but I already changed the path on server.php
did I missed anything?
My .htaccess under httpdocs
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
the one reason is you wouldn't have set permission for your public folder. Another you would need 5.5+ php version in order to make Laravel work. First set permission and try changing php version. I strongly believe this would work.
An one issue in my zend, i write rule in .htaccess to remove "public" from url as following,
------------------------------------------------------------------------
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain-name.com/$ [OR]<br/>
ReWriteCond %{REQUEST_URI} !public/<br/>
ReWriteRule ^(.*)$ public/$1 [L]<br/>
------------------------------------------------------------------------
but there is ROUTE method in zend, i have use it for multiple language to set language code in url LIKE www.domain-name.com/en/ , using zend_controller_router_route_chain,
before this method implemented, my url is www.domain-name.com but
when i use this method in my zend project, may be it overwrites .htaccess rule of removing "public" from URL or something happen using same and "public" is displaying in url like www.domain-name.com/public.
so IS THERE ANY METHOD OR TRICK TO REMOVE PUBLIC FROM URL USING ANY METHOD OF ROUTE IN ZEND FRAMEWORK ???
Thanks,
MRJethva.
The following works for me using ZF2.2
Create index.php on ZF2 root directory and add the following content:
<?php
define('RUNNING_FROM_ROOT', true);
include 'public/index.php';
Create .htaccess on ZF2 root directory and add the following content:
SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteRule .* index.php
Finally, add this conditional statement in the top of your layout.phtml file:
<?php
if (defined('RUNNING_FROM_ROOT')) {
$this->plugin('basePath')->setBasePath($this->basePath().'/public');
} ?>
Enjoy!
Reference: http://akrabat.com/zend-framework/zend-framework-on-a-shared-host/
Yes, and you don't need Zend_Route. Delete the public folder and put the Zend Framework files from it (index.php, .htaccess, etc) in your root directory (e.g. htdocs). You can place the application folder and other Zend Framework files outside of your web root where they cannot be accessed over HTTP.
All you need to do is edit index.php and change the APPLICATION_PATH to the correct path. This way your Zend Application will run from your root directory and you won't need to use mod_rewrite to hide the public folder.
See the last part of this answer for a similar example.
zf2 and zf3 remove Public from URL
create index.php and .htaccess add file in root of project
add the line in index.php
include_once("public/index.php");
and in .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]
after that go to following path
Module->application(module name)->view->layout->layout.phtml
change css and js path add public in path
before
->prependStylesheet($this->basePath('css/bootstrap.min.css'))
->prependFile($this->basePath('js/bootstrap.min.js'))
after
->prependStylesheet($this->basePath('public/css/bootstrap.min.css'))
->prependFile($this->basePath('public/js/bootstrap.min.js'))
also in image path
I am starting a Zend application and I need to put it in a sub folder like this:
/subfolder
application
public
...
I did the following:
I set the base url in application.ini:
resources.frontController.baseUrl = "/subfolder"
I moved the .htaccess from the public folder directly into /subfolder, while changing the htaccess as follows:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ public/index.php [NC,L]
That's all I did. And everything works as expected. I can add controller blog with action view and can access it by calling:
/subfolder/blog/view
the url view helper and stuff work right too. The only thing that does not work is the default controller. So when I enter:
/subolder/
I get 403 (forbidden). If I enter
/subfolder/index
...it works. What am I missing?!
Thanks in advance!
teebee
you do not need to make any change in your zf public folder, just create an .htaccess file into the "/subfolder" directory with the following lines
# Rewrite rules
RewriteEngine on
RewriteRule (.*) ./public/$1
Replace
RewriteRule ^.$ public/index.php [NC,L]
with
RewriteRule ^.$ http://addressto/index.php [R=302,NC]
or
RewriteRule ^.*$ /public/index.php [NC,L]
i'm not sure if putting ZF folders other than public into publicly accessible folder is right.It will impose your site on security flaws. You must put ZF'S public folder' contents into your server`s public folder and put other folders into a non-publicly accessible folder.If you need more that one instance of your ZF application you may use Zend module system.Please refer to zend online documentation for more details.
I have an Zend Framework application with a subdomain that works well in my local development environment. Now I'm trying to put it on the live location, in a shared hosting environment. I have made the subdomain in DirectAdmin.
This is the default content of the .htaccess in public_html
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
I have removed the folder public_html/subdomain because I want that everything goes through index.php. But the problem is that if I go to subdomain.example.com I get a 500 Internal Server Error. How can I solve this?
This sounds like a host-specific issue. Typically, if you were running your own Apache server, you would create a VirtualHost directive that would point your subdomain to your application's public folder.
I know some hosts will treat each domain / subdomain as it's separate folder. If your host is expecting you to have a public_html/subdomain folder, why not try making the subdomain folder a symbolic link to your application's public folder?
ln -s /path/to/zf/public/folder /path/to/public_html/subdomain/folder