如何通过htaccess子域访问zf2中的公用文件夹[duplicate]

问题描述:

This question already has an answer here:

I am new in zf2. Please help me. I setup my new zend project on www.example.com/zend/ directory but it didn't call directly. Its call via www.example.com/zend/public

How can i access directly access by www.example.com/zend/ this url. I don't want to any changes in virtual host. I want only use of .htaccess file.

Kindly suggest me solution.

</div>

此问题已经存在 这里有一个答案: p>

  • 如何使用htaccess for localhost和host server从url中删除'/ public'? 2 answers span> li> ul> div>

    我是zf2的新手。 请帮助我。 我在 www.example.com/zend / code>目录下设置我的新zend项目 但它没有直接调用。 通过 www.example.com/zend/public code> p>

    如何通过访问www.example.com/zend / 代码>这个网址。 我不想对虚拟主机进行任何更改。 我只想使用 .htaccess code>文件。 p>

    请建议我解决。 p> div>

Setup an htaccess file in your /zend/ directory:

RewriteEngine On
RewriteBase /zend/
RewriteRule ^(?!public/)(.*)$ public/$1 [L]

This is not possible in Apache web server. You can define virtual hosts only in .conf files, but not in .htaccess files.