Zend Framework on shared hosting

2019-01-13 04:58发布

I'm new to Zend Framework. I would like to know how to implement zend framework on a shared hosting. Because of the zend framework folder structure all view files are put into the "public" folder.

Suppose

"/" is the main root folder for me and public is like "/public"

so that the url becomes "http://site/public/. .. .bla bla..."

is this correct?

or is there any other method?

i dont have any permission to create a virtual host.

so what to do?

I hope that you understood my question. If not, please ask me.

Thank you!

12条回答
老娘就宠你
2楼-- · 2019-01-13 05:26

The answer from ArneRie did not work for me and I finally ended up using Lorenzo Albertons solution. Hope this is helping others to get a faster solution.

RewriteEngine On

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]
查看更多
一夜七次
3楼-- · 2019-01-13 05:27

You should place your project's Public folder to www folder in the host, so your address will become yourdomain.com/. Your source code folder such as library, applications... should be place at same level with www folder, not within it. This method will promote the security of your site

查看更多
小情绪 Triste *
4楼-- · 2019-01-13 05:28

Include this .htacces file under your base path (that is /../public):

RewriteEngine On

# Exclude some directories from URI rewriting
#RewriteRule ^(dir1|dir2|dir3) - [L]

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 leave the .htaccess that was under the publc directory where it was.

So you will have 2 .htaccess files, one under the public directory (the ordinary one from Zend Framework documentation) and second one under your base path (the one I posted above).

查看更多
爷的心禁止访问
5楼-- · 2019-01-13 05:30

I've been in the same situation and have put the zend libraries under a folder under public like 'src' - and use an .htaccess Deny from All. You'll have to juggle a couple paths, but it works fine.

查看更多
Emotional °昔
6楼-- · 2019-01-13 05:39

. . . How Magento uses Zend framework??? I'm using XAMPP and I did install Magento locally without modify php.ini, http.conf nor virtual host.

查看更多
男人必须洒脱
7楼-- · 2019-01-13 05:41

Indeed it's not the best idead to run Zend Framework applications on a shared hosting. I would really recommend getting a virtual private hosting (VPS). There are very good and inexpensive hostings out there with Zend Framework and other frameworks already installed and regularly updated. I'm on servergrove and it has been great so far!

But this doesn't mean that you can't make it work on a shared hosting. You just have to rather work with .htacess. Put the content of the public folder into your webroot and adjust your paths in the bootstrap.php, make sure all other folders cannot be accesses directly and use the usual ZF approach of routing everything through your index.php.

查看更多
登录 后发表回答