ovanes_budakyan
ovanes_budakyan

Reputation: 66

How to access an ZF2 application without “public” in URL

I completed my project on ZF2, then uploaded it on shared hosting. I would like a folder for the zend app with all the files inside, and then in the document root I would like the files from the public folder to be visible, because I want my URIs to look like www.example.com (not www.example.com/public/).

Upvotes: 1

Views: 1647

Answers (3)

ovanes_budakyan
ovanes_budakyan

Reputation: 66

This one work.

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]

Upvotes: 0

ACNB
ACNB

Reputation: 846

You can move the files inside /public to your webroot. However, please be aware that config files below your webroot are a security risk.

Upvotes: 0

Orangepill
Orangepill

Reputation: 24645

What I have done in those cases with ZF1 app is to throw an app directory in the document root and with your server's .htaccess equivalent made it not serve files from there (Deny from all). Then stick your gateway script into the document root and update the paths found in there including APPLICATION_ROOT and the path to the autoloader.

Hope this helps.

Upvotes: 2

Related Questions