Umgebung: CentOS
Apache Version: Apache/2.2.15http auf https Apache Umleitung .. Endlosschleife
Ich habe versucht, meine Website zu zwingen, https zu sein, aber in denen Endlosweiterleitungen
<VirtualHost *:443>
ServerName example.com
ServerAlias example
SetEnv HTTPS on
ProxyPreserveHost On
ProxyPass/http://localhost/
ProxyPassReverse/http://localhost/
SSLEngine on
SSLCertificateFile /ssl/star_ecom_sanmar_com.crt
SSLCertificateKeyFile /ssl/star_ecom_sanmar_com.key
SSLCertificateChainFile /ssl/DigiCertCA.crt
SSLProxyEngine on
<VirtualHost *:80>
ServerName example.com localhost
ServerAlias example
DocumentRoot ......
DirectoryIndex index.shtml index.html index.jsp
AddType text/html .shtml
AddHandler server-parsed .shtml
AddType application/x-httpd-php .php .php4
CustomLog /var/log/httpd/access_log combined env=!dontlog
ErrorLog /var/log/httpd/error_log
RewriteEngine on
RewriteCond "%{HTTPS}" !="on"
RewriteRule ^/(.*)$ https://example.com/$1 [R=301,L]
....
Die obige Rewrite-Regel wird immer ausgeführt, auch nachdem die Umleitung zu https beendet wurde, was zu einer Endlosschleife führt, die mich glauben lässt, dass der Wert von {HTTPS} niemals aktualisiert wird. Das gleiche gilt für {SERVER_PORT}, das immer 80 ist, auch wenn die Anfrage von https stammt. Unten finden Sie Ausgabe von PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}
pre {margin: 0px; font-family: monospace;}
a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
a:hover {text-decoration: underline;}
table {border-collapse: collapse;}
.center {text-align: center;}
.center table { margin-left: auto; margin-right: auto; text-align: left;}
.center th { text-align: center !important; }
td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
h1 {font-size: 150%;}
h2 {font-size: 125%;}
.p {text-align: left;}
.e {background-color: #ccccff; font-weight: bold; color: #000000;}
.h {background-color: #9999cc; font-weight: bold; color: #000000;}
.v {background-color: #cccccc; color: #000000;}
.vr {background-color: #cccccc; text-align: right; color: #000000;}
img {float: right; border: 0px;}
hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
</style>
<title>phpinfo()</title><meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" /></head>
<body><div class="center">
<h2>PHP Variables</h2>
<table border="0" cellpadding="3" width="600">
<tr class="h"><th>Variable</th><th>Value</th></tr>
<tr><td class="e">_SERVER["dontlog"]</td><td class="v">1</td></tr>
<tr><td class="e">_SERVER["SCRIPT_URL"]</td><td class="v">test.php</td></tr>
<tr><td class="e">_SERVER["SCRIPT_URI"]</td><td class="v">test.php</td></tr>
<tr><td class="e">_SERVER["HTTP_HOST"]</td><td class="v">example.com</td></tr>
<tr><td class="e">_SERVER["HTTP_UPGRADE_INSECURE_REQUESTS"]</td><td class="v">1</td></tr>
<tr><td class="e">_SERVER["HTTP_USER_AGENT"]</td><td class="v">Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36</td></tr>
<tr><td class="e">_SERVER["HTTP_ACCEPT"]</td><td class="v">text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8</td></tr>
<tr><td class="e">_SERVER["HTTP_ACCEPT_ENCODING"]</td><td class="v">gzip, deflate, sdch, br</td></tr>
<tr><td class="e">_SERVER["HTTP_ACCEPT_LANGUAGE"]</td><td class="v">en-US,en;q=0.8</td></tr>
<tr><td class="e">_SERVER["HTTP_X_FORWARDED_FOR"]</td><td class="v">::1</td></tr>
<tr><td class="e">_SERVER["HTTP_X_FORWARDED_HOST"]</td><td class="v">example.com</td></tr>
<tr><td class="e">_SERVER["HTTP_X_FORWARDED_SERVER"]</td><td class="v">example.com</td></tr>
<tr><td class="e">_SERVER["HTTP_CONNECTION"]</td><td class="v">Keep-Alive</td></tr>
<tr><td class="e">_SERVER["PATH"]</td><td class="v">/sbin:/usr/sbin:/bin:/usr/bin</td></tr>
<tr><td class="e">_SERVER["SERVER_SIGNATURE"]</td><td class="v"><address>Apache/2.2.15 (CentOS) Server at example.com Port 80</address>
</td></tr>
<tr><td class="e">_SERVER["SERVER_SOFTWARE"]</td><td class="v">Apache/2.2.15 (CentOS)</td></tr>
<tr><td class="e">_SERVER["SERVER_NAME"]</td><td class="v">example.com</td></tr>
<tr><td class="e">_SERVER["SERVER_ADDR"]</td><td class="v">::1</td></tr>
<tr><td class="e">_SERVER["SERVER_PORT"]</td><td class="v">80</td></tr>
<tr><td class="e">_SERVER["REMOTE_ADDR"]</td><td class="v">::1</td></tr>
<tr><td class="e">_SERVER["DOCUMENT_ROOT"]</td><td class="v">.....</td></tr>
<tr><td class="e">_SERVER["SERVER_ADMIN"]</td><td class="v">[email protected]</td></tr>
<tr><td class="e">_SERVER["SCRIPT_FILENAME"]</td><td class="v">test.php</td></tr>
<tr><td class="e">_SERVER["REMOTE_PORT"]</td><td class="v">57954</td></tr>
<tr><td class="e">_SERVER["GATEWAY_INTERFACE"]</td><td class="v">CGI/1.1</td></tr>
<tr><td class="e">_SERVER["SERVER_PROTOCOL"]</td><td class="v">HTTP/1.1</td></tr>
<tr><td class="e">_SERVER["REQUEST_METHOD"]</td><td class="v">GET</td></tr>
<tr><td class="e">_SERVER["QUERY_STRING"]</td><td class="v"><i>no value</i></td></tr>
<tr><td class="e">_SERVER["REQUEST_URI"]</td><td class="v">test.php</td></tr>
<tr><td class="e">_SERVER["SCRIPT_NAME"]</td><td class="v">test.php</td></tr>
<tr><td class="e">_SERVER["PHP_SELF"]</td><td class="v">test.php</td></tr>
<tr><td class="e">_SERVER["REQUEST_TIME"]</td><td class="v">1483559123</td></tr>
</table><br />
</div></body></html>
Bitte geben
behoben, die unter Bedingung auch, aber immer noch unendliche Umleitung Schleife erhalten. RewriteCond% {SERVER_PORT} = 80 \t RewriteRule ^/(. *) $ Https://example.com/$1 [R = 301, L] – faheem205