I've strange for me personally problem. I am developing Zend Framework application and also have this file structure:

/

/application/

/public/

/public/.htaccess

/public/index.php

/public/js/

/public/style/

/public/profile/

/.htaccess

My domain indicate folder /

After I go into the address example.com/profile/ it is going towards the controller profile which is nice. After I go into the address example.com/profile the server redirects me to: example.com/public/profile/

I must possess a solution any time I request: example.com/profile/ or example.com/profile

Exactly the same page is going to be made but second version provides me with a redirect and I'm not sure why.

The /.htaccess file is:

RewriteEngine On

RewriteRule ^(.*)$ public/$1 [L]

The role of the file would be to route all traffic from / to /public but with no redirects.

The /public/.htaccess file is:

RewriteEngine On

RewriteCond % -s [OR]

RewriteCond % -l

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ index.php [NC,L]

Can anybody assist me to with this particular? Thanks.


I fixed this. This is actually the solution if somebody have a similar problem: To repair this you need to set the next options and disable DirectorySlash

Options -Indexes FollowSymLinks

DirectorySlash Off

Now Apache should not add trailing slashes in the finish of uri whenever you pointing to directory. This disable redirect towards the uri with trailing slash.

Optionally match the final /. Improve your .htaccess file for this:

RewriteEngine On

RewriteRule ^(.*)/?$ public/$1 [L]

This works best for me:

RewriteEngine On

RewriteRule ^/$^(.*)$  /public/$1 [QSA,NC,L]