comboyzq 发表于 2010-5-22 02:40:05

Nginx进行REWRITE 301跳转后地址栏仍然显示跳转后URL是为何呢?

Nginx的rewrite如下

rewrite ^/work(.*)$ http://$host/work/index.php$1 permanent;

但我在访问 work/xxx 跳转后 仍然显示 work/index.php/xxx如何在跳转后仍然显示work/xxx

haohailuo 发表于 2010-5-22 07:17:39

把规则改成 rewrite ^/work(.*)$ http://$host/work/index.php$1 last;试试
也就是将最后的permanent改为last

comboyzq 发表于 2010-5-22 10:29:45

把规则改成 rewrite ^/work(.*)$ http://$host/work/index.php$1 last;试试
也就是将最后的permanent改为la ...
haohailuo 发表于 2010-5-22 07:17 http://codeigniter.org.cn/forums/images/common/back.gif


    我试了下 仍然没用 我的nginx.conf里这个server是这样写的 是不是和其他的location有关系
server
       {
               listen       80;

               server_namelocalhost;
               index index.html index.htm index.php;
               root/soft/vshare/htdocs;
                location /
                {
                  if ( -d $request_filename )
                  {
                  rewrite "^/(.*)([^/])$" http://$host/$1$2/ permanent;
                  }
                }
                location /work/
                {
                  rewrite ^/work(.*)$ http://$host/work/index.php$1 last;
                }
               location ~ ^(.+\.php)(.*)
                {
                  include fcgi.conf;
                  fastcgi_pass127.0.0.1:9000;
                  fastcgi_index index.php;
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$")
                {
                        set $real_script_name $1;
                        set $path_info $2;
                }
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
                }
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
                                     '$status $body_bytes_sent "$http_referer" '
                                     '"$http_user_agent" $http_x_forwarded_for';
               access_log/soft/logs/access.logaccess;
       }

       server
       {
               listen80;
               server_namelocalhost;

               location / {
                  stub_status on;
                  access_log   on;
               }
       }

haohailuo 发表于 2010-5-22 10:57:13

回复 3# comboyzq

location /
                {
                  if ( -d $request_filename )
                  {
                  rewrite "^/(.*)([^/])$" http://$host/$1$2/ permanent;
                  }
                }

与你这一段有关系吧

comboyzq 发表于 2010-5-22 11:17:23

回复comboyzq

location /
                {
                  if ( -d $request_filename )
         ...
haohailuo 发表于 2010-5-22 10:57 http://codeigniter.org.cn/forums/images/common/back.gif


    这里是个自动为目录请求添加“/”的语句 但我把这个rewrite注释掉后仍然不行   郁闷啊 。。。。。 是不是Nginx 有什么设置没打开?
页: [1]
查看完整版本: Nginx进行REWRITE 301跳转后地址栏仍然显示跳转后URL是为何呢?