我已经搜索过 - 并尝试过 - 在stackoverflow上列出了许多不同的方法来尝试将http://重定向到https://,但我不断获得重定向循环。
e.g。
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
我认为这是因为htaccess文件中的某些内容 - 在我在顶部添加任何这些https重定向(在RewriteEngine On下面)之前工作正常。 这是我目前的htaccess文件:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+home\.php\?su=([^\s&]+) [NC]
RewriteRule ^ /%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /home.php?su=$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/(prog|weblinks|photos|cal|officials|contactus|search)\.php\?su=([^\s&]+) [NC]
RewriteRule ^ /%2/%1.html? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(prog|weblinks|photos|cal|officials|contactus|search).html$ /$2.php?su=$1 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/content\.php\?su=([^\s&]+)&PgID=(\d+)&pu=([^\s&]+) [NC]
RewriteRule ^ /%1/%2/%3? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(\d+)/([^/]+)\.html$ /content.php?su=$1&PgID=$2&pu=$3 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/completed\.php\?su=([^\s&]+)&RoYear=([^\s&]+) [NC]
RewriteRule ^ /%1/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)\.html$ /completed.php?su=$1&RoYear=$2 [L,QSA]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/thumbs\.php\?su=([^\s&]+)&PgID=(\d+)&pu=([^\s&]+) [NC]
RewriteRule ^ /%1/thumbs/%2/%3? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/thumbs/(\d+)/([^/]+)\.html$ /thumbs.php?su=$1&PgID=$2&pu=$3 [L,QSA]
非常感谢任何指针 - 这是我运营的慈善网站。
干杯 克里斯
答案 0 :(得分:0)
我们尝试了很多变种,但最终有效的变种是 RewriteCond%{ENV:HTTPS}!=开启 RewriteRule(。*)https://% {HTTP_HOST}%{REQUEST_URI} [R = 301,L]
感谢@anubhava的努力