首页 > 代码库 > nginx rewriter配置

nginx rewriter配置

rewriter配置

nginx.conf配置

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
    server {
 
         listen  80;
         server_name 127.0.0.1;
         index index.php;
         root  /usr/share/nginx/html;
         #rewrite ^/projects/BookLibrary2/public$  /projects/BookLibrary2/public/index.php;
         #include /usr/share/sidamingzhu.conf;
              
         location / {
              
                                 if (!-e $request_filename) {
                                         rewrite ^/(.*)$ /projects/BookLibrary2/public/index.php last;
                                 }
          }         
              
        location ~ \.php$ {            #对.php文件调用php的fastcgi.exe处理
           #root html;
           fastcgi_pass   127.0.0.1:9000;
           fastcgi_index  index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include        fastcgi_params;
        }    
 
    }
 
}

  

fpm-php.conf需要配置監聽端口

?
1
#加在fpm-php.conf最後一行<br>listen = 127.0.0.1:9000