I am working on a yii2 project and would like to deploy it on an Apache server, where it is expected that the entire website will exist in the / public _html directory, and / public_html is the web root node for this host. The problem is that yii2 expects the web root to be / web, and expects that most of the site hierarchy will exist outside of the / web directory.
I would prefer not to change the website in / public _html / web, and for future projects this may not be an option. So, is there a way to put the entire site hierarchy in / public _html and still work correctly with the site?
I tried to create a file / public _html / .htaccess with the following contents:
RewriteEngine on
RewriteCond %{REQUEST_URI} !web/
RewriteRule (.*) /web/$1 [L]
And that seemed to work right at the beginning. Nothing outside / public _html / web was accessible and the files in the / web subdirectories, such as /web/js/signup.js, which could be accessed via the url http: //localhost/js/signup.js , but this led to my routing rules (which were configured on the local system where I could have a web root pointing to / web) no longer being recognized.
So, I would be pleased either with an alternative to the .htaccess path, or with a suggestion on how to fix the routing rules to work with the .htaccess route.
Edit to clarify
-, - ~/public_html. Yii , , www public_html , /www, ~, dotfiles , Linux ~. , , ( webroot).
, :
~/
|
|
|
|
|
|
|
|