Htaccess unexpectedly redirects to folder

I have a strange problem for me. I am developing a Zend Framework application and have the following structure:

/
/application/
/public/
/public/.htaccess
/public/index.php
/public/js/
/public/style/
/public/profile/
/.htaccess

My domain points to folder /

When I enter the address example.com/profile/, it goes to the controller profile, and that’s good. When I enter the address example.com/profile, the server redirects me to: example.com/public/profile/

I would like to have a solution which, when I ask: example.com/profile/or example.com/profile

The same page will be displayed, but the second version gives me a redirect, and I do not know why.

File /.htaccess:

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

The role of this file is to route all traffic from / to / public, but without any redirects.

File /public/.htaccess:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

Can someone help me? Thank.


. , - : , DirectorySlash

Options -Indexes FollowSymLinks
DirectorySlash Off

Apache uri . uri .

+5
2

/. .htaccess :

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

:

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

All Articles