回答編集履歴

1

追記

2017/09/25 09:56

投稿

TaichiYanagiya
TaichiYanagiya

スコア12146

test CHANGED
@@ -19,3 +19,71 @@
19
19
 
20
20
 
21
21
  試していませんが、**/shop/** より **\.php$** を優先させたいのであれば、`location /shop/` でどうなるでしょうか?
22
+
23
+
24
+
25
+ ---
26
+
27
+ **(2017/09/25 19:00) 追記**
28
+
29
+ `alias` を使っているのですね。
30
+
31
+
32
+
33
+ ###方法1: rewrite を使って /shop/ を省く
34
+
35
+ ```
36
+
37
+ location ^~ /shop/{
38
+
39
+ alias /var/www/php/;
40
+
41
+ index index.php;
42
+
43
+ try_files $uri $uri.php $uri/ 404.html=404;
44
+
45
+ rewrite ^/shop/(.+\.php) $1;
46
+
47
+ }
48
+
49
+ ```
50
+
51
+
52
+
53
+ ###方法2: location /shop/ の中で .php を扱う
54
+
55
+
56
+
57
+ `fastcgi_split_path_info` で /shop/ を省く。
58
+
59
+ ```
60
+
61
+ location ^~ /shop/{
62
+
63
+ alias /var/www/php/;
64
+
65
+ index index.php;
66
+
67
+ try_files $uri $uri.php $uri/ 404.html=404;
68
+
69
+
70
+
71
+ location ~ \.php$ {
72
+
73
+ fastcgi_pass 127.0.0.1:9000;
74
+
75
+ fastcgi_index index.php;
76
+
77
+ fastcgi_split_path_info ^/shop/(.+\.php)(.*);
78
+
79
+ fastcgi_param SCRIPT_FILENAME /var/www/php/$fastcgi_script_name;
80
+
81
+ include /etc/nginx/fastcgi_params;
82
+
83
+ }
84
+
85
+ }
86
+
87
+ ```
88
+
89
+