0

I have read the doc from Yii2 official website to deploy yii2 into share host from this : http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html, and about discussion on this : stackoverflow.

So, I decide to use sftp to upload the yii2 folder. And this is the list of directory in my share host.

access-logs
etc
logs
public_ftp
public_html
ssl
www (this is a link folder to public_html)

You know, because the share host can hold on domains untill 5 domains, is it possible to upload yii2basic folder into public_html folder ?

So the result like this :

access-logs
etc
logs
public_ftp
public_html
    -basic
        - bunch of yii folders here
ssl
www (this is a link folder to public_html)

Because now, if I want to access my web, I have to write like this : mydomain.com/basic/public_html/index.php

I need like this :

mydomain.com/index.php

Please guide me.

4
  • Have you got the ability to make public_html a symlink to other folder? Commented Aug 18, 2017 at 19:26
  • By default on provider, 'www' folder is symlink to public_html Commented Aug 18, 2017 at 19:30
  • This is not what I asked... Commented Aug 18, 2017 at 19:31
  • well this is the simplest yii deployment guide on cloud server and you can easily create a web root path to serve your app from domain.com. cloudways.com/blog/install-yii-2-framework-on-cloud Commented Aug 7, 2018 at 8:37

2 Answers 2

1

Yes you can upload it inside the public_html folder but the only problem that I have been facing nowadays with yii2 basic app is the pretty URLs, you can clone or upload entire contents inside the public_html folder, what I did is as follows only the difference is I have a web folder instead of www

directory structure

public_html
  assets
  commands
  config
  controller
  mail
  migrations
  models
  runtime
  tests
  vendor
  views
  web

public_html/.htaccess

<IfModule mod_rewrite.c>
    Options +SymLinksIfOwnerMatch
    RewriteEngine On
</IfModule>

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_URI} ^/.*
    RewriteRule ^(.*)$ web/$1 [L]

    RewriteCond %{REQUEST_URI} !^/web/
    RewriteCond %{REQUEST_FILENAME} !-f [OR]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^.*$ web/index.php
</IfModule>

public_html/web/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ /index.php?/$1 [L]

this works but in the URL it shows /web/index.php?r=site/index and as soon as I turn the prettyUrl on in the config file urlManager it would only show default index page and every link I try to open ends up on the home page view although the URL in the address bar is correct and urlManager parses the rules correctly, this is as far as I have gone.

Sign up to request clarification or add additional context in comments.

Comments

0

If you don't mind bunch of Yii 2 folders in your root folder just place all basic template folders (except web) and files in the root folder. Then place the content of web folder in the public_html folder.

It should be something like:

access-logs
assets
commands
config
controllers
etc
logs
mail
models
public_ftp
public_html
    // here should be the content of web folder of Yii 2 basic app
runtime
ssl
test
views
widgets

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.