How to access public folder in zf2 by htaccess sub

2019-09-01 14:51发布

问题:

This question already has an answer here:

  • how can remove '/public' from url using htaccess for localhost and host server? 2 answers

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.

回答1:

Setup an htaccess file in your /zend/ directory:

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


回答2:

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