⬆️ ⬇️

Shared Hosting & mod_rewrite

A little advice for those who write applications on the Zend Framework using the directory structure recommended in the manual and, by default, in Zend_Tool and places them for one reason or another on shared hosting.



The structure of your directories is:

projectname/<br> application/<br> controllers/<br> views/<br> scripts/<br> library/<br> public/<br> tests/
The public directory contains files that should be given to the user by the web server, therefore it should be installed as a DOCUMENT ROOT. The problem is that some hosters do not provide access to changing this parameter, as well as to directories higher level, i.e. when you connect via FTP, the highest level you can get to is inside DOCUMENT ROOT.



Without changing the directory structure, this problem can be solved by removing the standard .htaccess from the “public” and placing the next .htaccess in the root:

RewriteEngine On<br> <br>RewriteRule ^\.htaccess$ - [F]<br> <br>RewriteCond %{REQUEST_URI} =""<br>RewriteRule ^.*$ /public/index.php [NC,L]<br> <br>RewriteCond %{REQUEST_URI} !^/public/.*$<br>RewriteRule ^(.*)$ /public/$1<br> <br>RewriteCond %{REQUEST_FILENAME} -f<br>RewriteRule ^.*$ - [NC,L]<br> <br>RewriteRule ^public/.*$ /public/index.php [NC,L]


PS

Also this option is perfect for the user of the Denwer package.


')

Source: https://habr.com/ru/post/63053/



All Articles