2016-04-04 29 views
0

私はnginxの書き換えをしようとしています。動作していますが、サブディレクトリの場合、個々のサブディレクトリ内のindex.phpではなく、ルートのindex.phpを使用しています。Nginxはサブディレクトリを書き換えます

/index.php 
/p/index.php 
/c/index.php 

と、これは私のリライトです:

if (!-e $request_filename){ 
    rewrite ^/([^./]+)/?$ /index.php?act=$1 break; #need break? 
    rewrite ^/([^./]+)/(.+)/?$ /index.php?act=$1&upm=$2 break; 
    rewrite ^/([^./]+)/([^./]+)/?$ /$1/index.php?act=$2; 
} 

が、私は、各サブディレクトリのエントリを追加しようとしたが、それはどちらか動作しません。

location /p/ { 
     root /home/user/public_html/p/; 
     rewrite ^/([^./]+)/(.+)/?$ /index.php?act=$1&upm=$2 break; 
    } 
私のディレクトリ構造がどのように見えるかです

アイデア

答えて

0

rewrite ^/([^./]+)/([^./]+)/?$ /$1/index.php?act=$2;は、以前のリライトが常に一致するため、決して実行されません。 #2と#3の書き換えを入れ替えてみてください。

はおそらく/p/$document_root$uriの2倍で表示されるため、間違っている可能性があります。

location /p/rewrite/p/index.phpに書き換え、/index.phpに書き換えないでください。

関連する問題