Zend Framework 2 without Vhost configuration

后端 未结 1 1320
时光说笑
时光说笑 2020-12-30 17:54

I had finished my first web application using Zend Framework 2 and I\'m about to put it online. But may web host doesn\'t allow me to change my vhost configuration! The .hta

相关标签:
1条回答
  • 2020-12-30 18:14

    Assuming you have a standard ZF2 application based of the skeleton, then try creating a .htaccess file in the root with this in it:

    RewriteEngine On
    
    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]
    

    I haven't tested this, but in theory, this should effectively move the document root to the public directory while keeping it out of the url.

    0 讨论(0)
提交回复
热议问题