Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inside subdirectory #22

Open
neoacevedo opened this issue Aug 5, 2021 · 1 comment
Open

Inside subdirectory #22

neoacevedo opened this issue Aug 5, 2021 · 1 comment

Comments

@neoacevedo
Copy link

How should I to configure my .htaccess if I need to run the app advanced inside a subdirectory to access to it as web subdirectory, e.g: www.mysite.tld/app-advanced ?

@mickgeek
Copy link
Owner

mickgeek commented Jun 11, 2022

Hi.

Your virtual host configuration should be like follow that:

<VirtualHost *:80>
    ServerName 0.0.0.0
    DocumentRoot /home/app

    <Directory />
        DirectoryIndex index.html

        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Create and edit the application files. The /home/app/yii2-app-advanced/.htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_URI} ^
RewriteRule ^ frontend/web%{REQUEST_URI}
RewriteRule /admin backend/web%{REQUEST_URI}

The /home/app/yii2-app-advanced/frontend/web/.htaccess and /home/app/yii2-app-advanced/backend/web/.htaccess files:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

The /home/app/yii2-app-advanced/frontend/config/main.php file:

'homeUrl' => '/yii2-app-advanced',
'components' => [
    'request' => [
        'baseUrl' => '/yii2-app-advanced',
    ],
    'assetManager' => [
        'baseUrl' => '/yii2-app-advanced/frontend/web/assets',
    ],
...

The /home/app/yii2-app-advanced/backend/config/main.php file:

'homeUrl' => '/yii2-app-advanced/admin',
'components' => [
    'request' => [
        'baseUrl' => '/yii2-app-advanced/admin',
    ],
    'assetManager' => [
        'baseUrl' => '/yii2-app-advanced/backend/web/assets',
    ],
...

Also modify the /home/app/yii2-app-advanced/frontend/assets/AppAsset.php and /home/app/yii2-app-advanced/backend/assets/AppAsset.php files: the $baseUrl variable should be /yii2-app-advanced/frontend/web and /yii2-app-advanced/backend/web respectively.

The server version: Apache/2.4.53. Sorry for the late answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants