Configure Frontend & Backend Url in Yii2 (Part 1)

Configure Frontend & Backend Url in Yii2 (Part 1)


yii2 shared hosting upload

Easy configure frontend & backend url in yii 2. This tutorial show how to configure frontend url default ‘frontend/web’ can be hiding and backend url change to administrator using .htaccess files. So, we can acces our website using base url. e.g and backend

Configure Frontend & Backend Url in Yii2 (Part 2) :

The step is easy:
1. Create .htaccess file in root directory
2. Create .htaccess file in frontend directory
3. Copy .htaccess file in frontend directory to backend directory
4. add ‘homeUrl’ and ‘baseUrl’ in backend config file.

This tutorial is based from

9 thoughts on “Configure Frontend & Backend Url in Yii2 (Part 1)

  1. Thank you so much
    but i have a problem
    my theme assets get errors and they can't find the /admin directory for load the assets
    how can i fix this?
    thanks again.

  2. #Frontend folder Backend folder
    RewriteEngine on

    # If a directory or a file exists, use it directly

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    # Otherwise forward it to index.php

    RewriteRule . index.php

  3. #Root htaccess

    # prevent directory listings

    Options -Indexes

    IndexIgnore /

    # follow symbolic links

    Options FollowSymlinks

    RewriteEngine on

    RewriteRule ^administrator (/.+)?$ backend/web/$1 [L,PT]

    RewriteRule ^(.+)?$ frontend/web/$1

  4. I did everything just like you explained it but what is get is Server error! Error 500! , when i try to reach localhost/eshop/ . Can you give me an advice?

Leave a Reply

Your email address will not be published. Required fields are marked *