【发布时间】:2010-11-24 20:34:22
【问题描述】:
我正在开发服务器上用 nginx 替换 lighttpd。我让它与 PHP 和 SSL 一起工作,但我对应该是一个简单的重写感到困惑。我需要从
重写 URLhttp[s]://dev.foo.com/signup/123456
到
http[s]://dev.foo.com/signup/index.php?attcode=123456
我使用的规则是:
rewrite ^/signup/([0-9]+)$ /signup/index.php?attycode=$1 last;
我已经尝试了很多变化,移动它,把它放在一个位置块内。发生的情况是 URL 被重写为:
http://dev.foo.com/dev.foo.com/signup/123456
主机名插入了,好像总是丢https,去http。
我的 nginx.com 服务器部分如下。我已经阅读并重新阅读了 nginx 文档(原样)并搜索了 nginx 邮件列表,但我尝试过的都没有解决这个问题。
Ubuntu 8.0.4 LTS 以防万一。
谢谢。
server {
listen 80;
listen 443 default ssl;
server_name dev.foo.com dev.bar.com localhost;
root /var/www/foo;
index index.php index.html;
# ssl cert stuff omitted
charset utf-8;
access_log /var/log/www/dev.access.log main;
location ~ /\. {
deny all;
}
location ~* ^.+\.(inc|tpl|sql|ini|bak|sh|cgi)$ {
deny all;
}
location ~* ^/(scripts|tmp|sql)/ {
deny all;
}
rewrite ^/robots.txt$ /robots_nocrawl.txt break;
rewrite ^/signup/([0-9]+)$ /signup/index.php?attycode=$1 last;
location / {
try_files $uri $uri/ /error_404.php;
}
location ~ \.php$ {
fastcgi_pass localhost:51115;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SERVER_NAME $http_host;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
error_page 404 /error_404.php;
}
【问题讨论】: