網(LieHuo.Net)教程 Windows下Nginx+PHP CGI+QeePHP好看又好用的rewrite配置
以下為引用的內容: root E:/HTML; location / { index index.php index.html index.htm; if (!-f $uri){ set $rule_0 1$rule_0; } if (!-d $uri){ set $rule_0 2$rule_0; } #注意順序,21與12,結果可不一樣 代碼來自:網,更多:www.wfuwu.com if ($rule_0 = "21"){ #Nginx沒有虛擬目錄的概念,所以繞開這個問題,加第一組正則匹配。 rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/([a-z-A-Z]+)/?(.*)$ /$1/index.php?controller=$2&action=$3&$4; rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/?$ /$1/index.php?controller=$2 last; #這樣搞,就可支持X.X.X.X/any_app/controller/action #在你的應用程序config的環境文件里,dispatcher_url_mode為rewrite, #當再使用url("some_controller/some_action"),完美了! } } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #一些JS、圖片、CSS等靜態文件,就不要rewrite了,要不然不正常。開發模式下,把超期設置注釋掉。 location ~* ^.+.(js|ico|gif|jpg|jpeg|pdf|png|css)$ { access_log off; expires 7d; } location ~ .php?$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME E:/HTML$fastcgi_script_name; } location ~ /.ht { deny all; } |