I have a Zend Framework application with a .htaccess file in the root directory, directing all traffic to the /public directory, where index.php resides.
This is the contents of the .htaccess:
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_URI} =""
RewriteRule ^.*$ /public/index.php [NC,L]
RewriteCond %{REQUEST_URI} !^/(upload|img|js|css|less)/.*$
RewriteCond %{DOCUMENT_ROOT}/public/upload%{REQUEST_URI} -f
RewriteRule ^(.+\.(jpg|png|mp3))$ /public/upload%{REQUEST_URI} [NC,L]
;RewriteCond %{REQUEST_URI} !^/public/.*$
;RewriteRule ^(.*)$ /public/$1
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [NC,L]
RewriteRule ^public/.*$ /public/index.php [NC,L]
As you can see, there are two commented out lines.
The section, supposedly directing traffic to /public, and which works on my local servers and my shared host, seems to fail miserably on my client’s server.
So, with the two lines commented out, when I type the site’s address in the browser, I get a directory listing. When I append /public to the address, I’m taken to /public/index.php, as expected, but since the request wasn’t redirected correctly, neither are the ones to the JS and CSS files.
When I uncomment the lines, I get a 500 internal server error (index.php is not reached at all).
The other rewrites work correctly (at least as far as I can tell).
Any ideas why this would happen and how to correct this?
Thanks in advance.
Save yourself a lot of grief and do the following:
publicdirectory..htaccessfile in thepublicdirectory.Ok, given your shared hosting constraints, try this one out…
publicfiles into your document root including the.htaccessfile mentioned in step #2 aboveapplication,library) anywhere in the filesystem, preferably outside the web document root. An example might be/home/user/apps/my-app-name/Modify the
index.phpfile with the newAPPLICATION_PATH, egNow everything should “just work” and your site won’t be accessed with the word “public” in the URL.