我正在使用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