nginx配置網站的二級目錄專案偽靜態
阿新 • • 發佈:2019-01-26
因為業務需求,需要在網站的二級目錄下建立一個新專案shuicao,新專案也要用url重寫的方式訪問,比如www.xxx.com/shuicao/.......。試著配置了一下nginx的重寫規則,如下:
location / { index index.html index.htm index.php l.php; autoindex off; if (!-e $request_filename) { #地址作為將引數rewrite到index.php上。 rewrite ^/(.*)$ /index.php/$1 last; } } location /shuicao/ { index index.html index.htm index.php l.php; autoindex off; if (!-e $request_filename){ rewrite ^/shuicao/(.*)$ /shuicao/index.php/$1 last; } }
重啟nginx即可生效。