Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将单页https重写为http Nginx_Php_Ssl_Joomla_Nginx_Rewrite - Fatal编程技术网

Php 将单页https重写为http Nginx

Php 将单页https重写为http Nginx,php,ssl,joomla,nginx,rewrite,Php,Ssl,Joomla,Nginx,Rewrite,我想重写一下https://www.example.com“还有”https://example.com“到”http://www.example.com“或者”http://example.com 分别”。我只想写该网站的特定部分,而不是任何子文件夹或php相关页面。如何做到这一点?我在另一个方向上使用它(没有在这个方向上测试,但应该可以工作) 编辑:限制到某个位置并结束不要尝试重写更多: location / { if ( $scheme = https ) { rewrit

我想重写一下https://www.example.com“还有”https://example.com“到”http://www.example.com“或者”http://example.com 分别”。我只想写该网站的特定部分,而不是任何子文件夹或php相关页面。如何做到这一点?

我在另一个方向上使用它(没有在这个方向上测试,但应该可以工作)

编辑:限制到某个位置并结束不要尝试重写更多:

location / {
  if ( $scheme = https )
  {
    rewrite ^ http://$host$uri last;
  }
}

我使用了类似于以下内容的东西,它避免使用,而不是
rewrite
。但是它失败了,这让我很烦恼。。欢迎提出建议

server {
    listen 80;
    server_name .example.com;
    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php5-fpm.sock ;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

server {
    listen              443 ssl;
    server_name         .example.com;
    ssl_certificate     /etc/ssl/certs/example.com.cert;
    ssl_certificate_key /etc/ssl/private/example.com.key;

    index index.html index.htm index.php;

    # Rewrite only / to http
    location = / {
        return 301 http://$server_name$request_uri;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php5-fpm.sock ;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
另见


我只需要在人们访问url时重写,而不需要任何其他页面。该指令重写整个站点的URL。这是一种非常糟糕的做法。。。和@Ownatik:从您引用的页面:“如果在
位置
上下文中
可以在
内部执行的唯一100%安全的操作是:
返回…;
重写…最后;
”。这是第二种情况,你有更好的解决方案吗?
server {
    listen 80;
    server_name .example.com;
    index index.html index.htm index.php;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php5-fpm.sock ;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

server {
    listen              443 ssl;
    server_name         .example.com;
    ssl_certificate     /etc/ssl/certs/example.com.cert;
    ssl_certificate_key /etc/ssl/private/example.com.key;

    index index.html index.htm index.php;

    # Rewrite only / to http
    location = / {
        return 301 http://$server_name$request_uri;
    }

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass   unix:/var/run/php5-fpm.sock ;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}