امروز:دوشنبه ,۱۳۹۷/۱۱/۲۹
Download http://bigtheme.net/joomla Free Templates Joomla! 3
Home / Yii2 / حذف backend و frontend از xampp

حذف backend و frontend از xampp

.htaccess در root


Options +FollowSymlinks
RewriteEngine On
# deal with admin first
RewriteCond %{REQUEST_URI} ^/vaymand/(admin) 
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
RewriteCond %{REQUEST_URI} !^/vaymand/backend/web/(assets|css)/ 
RewriteCond %{REQUEST_URI} ^/vaymand/(admin)  
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/vaymand/(assets|css|uploads|vaymandshop)  
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteRule ^uploads/(.*)$ frontend/web/uploads/$1 [L]
#RewriteRule ^uploads/advertise(.*)$ frontend/web/uploads/advertise/$1 [L]
RewriteRule ^vaymandshop/(.*)$ frontend/web/vaymandshop/$1 [L]
RewriteCond %{REQUEST_URI} !^/vaymand/(frontend|backend)/web/(assets|css)/  
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php

.htaccess در frontend فولدر web

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L]

.htaccess در backendفولدر web

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L]

در فولدر common و در فولدر components
Request.php

namespace common\components;
class Request extends \yii\web\Request {
    public $web;
    public $adminUrl;
    public function getBaseUrl(){
        return str_replace($this->web, "", parent::getBaseUrl()) . $this->adminUrl;
    }
    public function resolvePathInfo(){
        if($this->getUrl() === $this->adminUrl){
            return "";
        }else{
            return parent::resolvePathInfo();
        }
    }
}

تنظیمات main.php در frontend

use \yii\web\Request;
return [
'request' => [
            'class' => 'common\components\Request',
            'web' => '/frontend/web'
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],
]

تنظیمات main.php در backend

use \yii\web\Request;
return [
'request' => [
 'class' => 'common\components\Request',
            'web' => '/backend/web',
            'adminUrl' => '/admin'
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],
]

Check Also

سایت چند زبانه با فریم ورک yii

سایت چند زبانه با فریم ورک yii مطلب که در این بخش قصد آموزش داریم …

پاسخ دهید

نشانی ایمیل شما منتشر نخواهد شد. بخش‌های موردنیاز علامت‌گذاری شده‌اند *