我有下/path/
nginx的重寫 - 文件存在,但被重寫需要
一切的PHP應用程序不存在(文件/目錄)將被重定向到/path/index.php
if (!-e $request_filename)
{
rewrite ^/path/(.+)$ /path/index.php last;
}
和一切正常開從實際的文件,因爲某些原因的.css存在仍然重定向到索引文件......如/path/CSS/style.css
UPDATE
固定rewrite ^/path/(.+)/$ /path/index.php last;
,因爲我的所有URL需要重寫末尾必須有斜線,但仍撲朔迷離
nginx.conf
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
全面啓用站點/文件
server {
listen valueyourvote.org.nz:80;
server_name valueyourvote.org.nz valueyourvote.co.nz;
if ($http_host != www.valueyourvote.org.nz) {
rewrite (.*) http://www.valueyourvote.org.nz$1;
}
access_log /var/log/nginx/valueyourvote.org.nz.access.log;
error_log /var/log/nginx/valueyourvote.org.nz.error.log;
location/{
root /var/www/vote.incode.co.nz/;
index index.php index.html index.htm;
}
if (!-e $request_filename)
{
rewrite ^/supercity-2010/(.+)/$ /supercity-2010/index.php last;
}
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
我想'try_files'基於信息在這裏http://michaelshadle.com/2009/03/19/finally-using-nginxs-try-files-directive但它並沒有幫助,也許在配置的其他地方會出現一些奇怪的現象,但它只是在Ubuntu的基礎上安裝的,所以它們應該沒問題 – 2011-05-04 21:59:28
如果你可以提供更多的nginx配置,也許我們可以找到bug :) – ZoFreX 2011-05-04 22:05:31
添加配置文件 – 2011-05-04 23:04:00