0
我nginx的版本是:Nginx的原因時,重定向服務器根目錄改變
[email protected]:/etc/nginx/conf.d# nginx -v
nginx: nginx version: nginx/1.0.5
我的應用程序被安裝在
/usr/share/nginx/www/magento/current
當我訪問
http://{my_server}:81/magento/current/index.php
它工作正常。這是因爲服務器根目錄設置爲/usr/share/nginx/www
;
現在我想使用http://{myserver}:81/index.php
訪問應用程序。 當我更改服務器根/usr/share/nginx/www/magento/current
並輸入上述網址,它與HTTP 302重定向到
http://{my_server}:81/magento/current
什麼可能是這個原因?
然後,它適用於從我的.conf其他規則,並給出了404
我看到這個在訪問日誌:
[31/Jul/2012:11:19:23 +0530] "GET /index.php HTTP/1.1" 302 5 "-" "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.10.229 Version/11.64"
我.conf文件:
server {
listen 81 default;
## SSL directives might go here
server_name {my_server};
#root /usr/share/nginx/www;
root /usr/share/nginx/www/magento/current;
error_log /var/log/nginx.error.log notice;
access_log /var/log/nginx.access.log ;
rewrite_log on;
location/{
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @magehandler; ## If missing pass the URI to Magento's front handler
#try_files $uri $uri/ ; ## If missing pass the URI to Magento's front handler
#expires 30d; ## Assume all files are cachable
}
location ^~ /. { ## Disable .htaccess and other hidden files
return 404;
}
location @magehandler { ## Magento uses a common front handler
#rewrite//index.php;
rewrite ^(.*) index.php$1 last;
}
#The more-specific regex are at the top.
#The regex's are evaluated in the order in which they appear.
location ~ .php$ { ## Execute PHP scripts
#if (!-e $request_filename) { rewrite//index.php last; } ## Catch 404s that try_files miss
proxy_read_timeout 120;
proxy_connect_timeout 120;
expires off; ## Do not cache dynamic content
fastcgi_pass 127.0.0.1:9000;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
location ~ /(media|skin|js)/ { }
location ~ /(tag|admin|customer|wishlist|checkout|catalog|app).*$ { #store URL
rewrite /(.*)$ /index.php/$1 last;
}
location ~ /[a-zA-Z]+$ { #store URL
rewrite ^/([a-zA-Z]+) ?store=$1 last;
}
location ~ /[a-zA-Z]+/ { #store URL
rewrite ^/([a-zA-Z]+)(.*) /$2?store=$1 last;
}