Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.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 .htaccess重写为https_Php_Ssl - Fatal编程技术网

Php .htaccess重写为https

Php .htaccess重写为https,php,ssl,Php,Ssl,因此,我想做以下工作: 如果用户试图转到index.php以外的网站的一部分,他们将被重定向到https版本 因此,如果他们试图转到example.com/index.php,他们不会被重定向到https版本 但是,如果他们访问index.php(比如welcome.php)以外的站点的任何部分,就会被重定向到https版本 以下是我以前如何进行完整站点https重定向(我不确定如何在index.php上进行完整站点重定向到https示例) 为了将除索引之外的所有页面重定向到https,请将以下

因此,我想做以下工作:

  • 如果用户试图转到index.php以外的网站的一部分,他们将被重定向到https版本

  • 因此,如果他们试图转到example.com/index.php,他们不会被重定向到https版本

  • 但是,如果他们访问index.php(比如welcome.php)以外的站点的任何部分,就会被重定向到https版本

  • 以下是我以前如何进行完整站点https重定向(我不确定如何在index.php上进行完整站点重定向到https示例)


    为了将除索引之外的所有页面重定向到https,请将以下内容添加到.htaccess文件中:

    RewriteCond %{HTTPS} !on
    RewriteRule !^(index)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
    
    可以使用括号内的管道字符添加其他异常,如下所示:

    RewriteRule !^(index|about|contact)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
    
    RewriteRule !^(index|about|contact)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}