2
votes

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:

  1. I set the base url in application.ini:
resources.frontController.baseUrl = "/subfolder"
  1. 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

2
Why would you move your .htaccess away from the public folder? That causes all sorts of issues, I think. - Adrian World
how else can I use subfolders then? Any better approach? - teebee
You don't have to confuse (and mix) your web folder structure and your locale file structure. Your Zend application can live wherever you want it to live on your web server. Your index.php has to find it, though. Your public (web) folder should only hold that index.php plus what needs to be accessed by a web browser, like CSS, images. According to your htaccess /subfolder exists and hence the index.php is not triggered but also the 403 error. - Adrian World

2 Answers

0
votes

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
0
votes

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.