php 引入公用文件夹,php – 使用ZF2时重定向到公用文件夹

我正在使用ZF2(Zend Framework 2,v2.2),我希望http://www.foo.com/path/to/app/重定向到公共文件夹.

我已经尝试了很多解决方案,但不是它们允许url指向/path/to/app/public/index.php,而只显示/ path / to / app /.

我很感激任何解决方案,因为我无法创建应用程序框架自述文件中描述的虚拟主机.

任何帮助非常感谢.

干杯,

格雷格.

解决方法:

简而言之,我在应用程序的根目录中添加了一个.htaccess文件:

RewriteEngine On

# If URL to the application is http://foo.com/path/to/ZendSkeletonApplication/

# the set the base to /path/to/ZendSkeletonApplication/

RewriteBase /path/to/ZendSkeletonApplication/

RewriteRule ^\.htaccess$- [F]

RewriteCond %{REQUEST_URI} =""

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

RewriteCond %{REQUEST_URI} !^/public/.*$

RewriteRule ^(.*)$public/$1

RewriteCond %{REQUEST_FILENAME} -f

RewriteRule ^.*$- [NC,L]

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

然后我更改了module / Application / config / module.config.php.

希望能帮助到你.

标签:htaccess,php,mod-rewrite,zend-framework2

来源: https://codeday.me/bug/20190831/1779174.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值