【发布时间】:2016-02-27 23:18:00
【问题描述】:
我已经搜索并尝试了 stackoverflow 上列出的许多不同方法来尝试将 http:// 重定向到 https://,但我不断收到重定向循环。
例如
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]
非常感谢任何指点 - 这是我经营的慈善网站。
干杯 克里斯
【问题讨论】:
-
感谢@anubhava 重定向地址出现在地址栏中,但开发人员框仅显示 [link] 'etc 处的页面无法加载,页面内容显示错误太多重定向
-
您在
Chrome dev tool的Networking标签中重复看到的网址是什么? -
我看到了正确的重定向网址,但状态为 302
-
重定向前是什么URL,重定向后又是什么?
-
@anubhava 这似乎无关紧要;它可能是 [链接] http:// 或 www。或两者兼而有之,它会使用之前存在的任何内容进行重定向,但使用 https。我会把它留在原地,这样你就可以看到 - www.rotary-site.org/websites-for-trf