Gre*_*egP 3 php .htaccess mod-rewrite zend-framework2
我正在使用ZF2(Zend Framework 2,v2.2),我希望http://www.foo.com/path/to/app/重定向到公共文件夹.
我已经尝试了很多解决方案,但不是它们允许url指向/path/to/app/public/index.php,而只显示/ path/to/app /.
我很感激任何解决方案,因为我无法创建应用程序框架自述文件中描述的虚拟主机.
任何帮助非常感谢.
干杯,格雷格.
我想出了一个解决方案:https://github.com/gpfister/ZendSkeletonApplication
简而言之,我在应用程序的根目录中添加了一个.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]
Run Code Online (Sandbox Code Playgroud)
然后我更改了module/Application/config/module.config.php.
它现在工作正常,但http://foo.com/path/to/ZendSkeletonApplication/public将失败,这很好,因为我不打算使用此URL访问应用程序.
希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
5859 次 |
| 最近记录: |