将Nginx conf转换为.htaccess文件

时间:2019-05-25 09:57:17

标签: apache .htaccess yii2-advanced-app nginx-config

我已经在Apache服务器中设置了现有的Yii2高级项目。在Nginx服务器上之前。我有一个nginx.conf文件。我想将其转换为.htaccess文件,以使项目也可以在Apache服务器上工作。

这是nginx.conf文件的代码

location / {
     index index.php index.html;
     try_files $uri $uri/ /index.php?$args;
} # / location

location /html {
    alias /../../html/;
}
location /api {
    if ( !-e $request_filename ) {
            rewrite ^/api/(.*)$ /api/index.php?$1 last;
    }
}
location /dten {
    if ( !-e $request_filename ) {
            rewrite ^/dten/(.*)$ /dten/index.php?$1 last;
    }
}
location /dten-backend {
    if ( !-e $request_filename ) {
            rewrite ^/dten-backend/(.*)$ /dten-backend/index.php?$1 last;
    }
} 
location /dten-crm {
    if ( !-e $request_filename ) {
        rewrite ^/dten-crm/(.*)$ /dten-crm/index.php?$1 last;
    }
}

我尝试了这个,但是没有用。

# 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


# Handle the case of backend, skip ([S=1]) the following rule, if current matcheds
RewriteRule ^/dten-backend(/(.*))?$ /dten-backend/$2 [S=1]

0 个答案:

没有答案