MVC structure on remote server

Asked

Viewed 92 times

0

I have the following directory structure in localhost:

-config
-hsapp
 |--Controllers
 |--Models
 |--Views
-public
 |--Assets
 |--Index.php
-vendor
composer.json

You notice it’s an MVC structure. I created a virtualhost right to the folder public, locally, and works perfectly.

I now need to upload to a folder on a web server, (domain.com.br/folder) but I don’t know how to configure why, when entering the folder, access the folder public so that it is the root folder, because the system works with routes.

Someone can give a light to a beginner?

Thank you very much.

  • the server is Cpanel?

  • Nao. I managed with the following rewrite: Rewriteengine On Rewritebase / Rewriterule (?!/public/)(.*)$ /public/$1 [L] but now it does not find the view.

  • It has nothing to do with MVC. Besides, it’s not clear enough about what needs to be done. Although it is obvious that the focus of the problem is to create a URL rewriting or something similar. You yourself commented that it solved but causes another problem with the views that I believe is related to CSS and JS loading (assumption). That is, unfeasible to provide a solution and has become too broad.

1 answer

1

You would have to set the document root as the public folder, example: Painel Cpanel

So if the site was accessed like this tmp.dominio.com or domain.com/tmp he would actually be accessing the directory public_html/tmp/public

  • 1

    I managed with the following rewrite: RewriteEngine On
RewriteBase /
RewriteRule ^(?!/public/)(.*)$ /public/$1 [L]

Browser other questions tagged

You are not signed in. Login or sign up in order to post.