我对我的问题很奇怪.我正在开发Zend Framework应用程序并具有以下文件结构:
/
/application/
/public/
/public/.htaccess
/public/index.php
/public/js/
/public/style/
/public/profile/
/.htaccess
我的域名指向文件夹/
当我输入地址example.com/profile/时,它会转到控制器配置文件,这很好.
当我输入地址example.com/profile时,服务器会将我重定向到:
example.com/public/profile/
我希望有一个解决方案,无论何时我要求:
example.com/profile/或
example.com/profile
将呈现相同的页面,但第二个版本给我一个重定向,我不知道为什么.
/.htaccess文件是:
RewriteEngine On
RewriteRule ^(.*)$public/$1 [L]
此文件的作用是将所有流量从/向/ public路由,但不进行任何重定向.
/public/.htaccess文件是:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^.*$- [NC,L]
RewriteRule ^.*$index.php [NC,L]
任何人都可以帮我吗?谢谢.
我修好了.如果有人遇到同样的问题,这是解决方案:
要解决此问题,您必须设置以下选项并禁用DirectorySlash
Options -Indexes FollowSymLinks
DirectorySlash Off
现在,当你指向目录时,Apache不应该在uri的末尾添加尾部斜杠.
这也禁用了使用尾部斜杠重定向到uri.
作者分享了在开发 Zend Framework 应用时遇到的URL路径问题,描述了如何通过.htaccess文件配置实现无斜杠和有斜杠请求的统一处理,最终找到并修复了导致重定向问题的解决方案。
3774

被折叠的 条评论
为什么被折叠?



