2017-08-01 10 views
0

私はnginxの書き換えに別の問題があります。nginx rewirteは2つの異なるフォルダ(フォルダ+サブフォルダ別のrewirte)

私はrootとサブディレクトリでhtaccessファイルを使用しています。

ルートフォルダに

使用:

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-l 
RewriteRule ^(.+)$ index.php?req=$1 [QSA,L] 
</IfModule> 

cpとサブフォルダ内:

しかし、私は、このことにより、nginxのを設定しよう:

しかし、私は試してみてください。

server { 
    listen  xx.xx.xx.xx:80; 
    server_name mydomain.net www.mydomain.net; 
    root  /home/admin/web/mydomain.net/public_html; 
    index  index.php index.html index.htm; 
    access_log /var/log/nginx/domains/mydomain.net.log combined; 
    access_log /var/log/nginx/domains/mydomain.net.bytes bytes; 
    error_log /var/log/nginx/domains/mydomain.net.error.log error; 

    #first block 
    location/{ 

    if (!-e $request_filename){ 
     rewrite ^(.+)$ /index.php?req=$1 last; 
     } 

    } 
    #second block  
    location /cp { 

    if (!-e $request_filename){ 
     rewrite ^(.+)$ /router.php?get=$1 last; 
     } 

    } 
} 

しかし、私はダウンロードの力PHPを試してみてください。

この問題は、私はこのことについて多くを検索し、私はルート上の第二のブロックの書き換え作業を削除すると、私は答え

を見つける傾ける他の問題のように見えません。

+0

PHPの処理場所:コンフィギュレーションのphp-処理場所をnginxのためにPHP-FPMを設定し、追加する必要があります処理PHP用の? –

+0

@AlexanderTolkachevロケーションルート '/'と 'cp'サブフォルダを処理する必要があります –

答えて

0

ロケーションの問題については、this answerを確認する必要があります。

location ~ \.php$ { 
     include fastcgi_params; 
     fastcgi_pass unix:/var/run/php-fpm.sock; 
     fastcgi_param SCRIPT_FILENAME /var/nginx/$fastcgi_script_name; 
     fastcgi_index index.php; 
    } 
関連する問題