Apache SSLredirect循环

我们正试图将我们的网站从httpredirect到https。 我们在.htaccess中试过的所有东西都导致了redirect循环。 如果我们手动在url前input“https://”,我们的页面会返回jQuery error! 。 所以我怀疑这是不是所有请求的资源都通过https请求?

我们的htaccess文件:

 RewriteEngine on RewriteCond %{HTTPS} !=on RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L] # change rewrite base if not in root RewriteBase / # api RewriteRule ^(api)($|/) - [L] # index.php RewriteRule ^index.php$ - [L] # pass-through RewriteRule ^(css|js|site)/.*$ - [L] # redirect errors ErrorDocument 400 /error/400/ ErrorDocument 401 /error/401/ ErrorDocument 403 /error/403/ ErrorDocument 404 /error/404/ ErrorDocument 500 /error/500/ RewriteRule ^error/(.*)/$ index.php?page=error&eid=$1 [L] # login RewriteRule ^login$ login/ [R] RewriteRule ^login/$ index.php?page=login # logout RewriteRule ^logout$ logout/ [R] RewriteRule ^logout/$ index.php?page=logout # ip requests RewriteRule ^request_ip$ request_ip/ [R] RewriteRule ^request_ip/$ index.php?page=request_ip # IE fix RewriteRule ^login/dashboard/$ dashboard/ [R] RewriteRule ^logout/dashboard/$ dashboard/ [R] # upgrade RewriteRule ^upgrade$ upgrade/ [R] RewriteRule ^upgrade/$ index.php?page=upgrade # install RewriteRule ^install$ install/ [R] RewriteRule ^install/$ index.php?page=install # dashboard RewriteRule ^dashboard/$ index.php?page=dashboard # widgets RewriteRule ^widgets/(.*)/$ index.php?page=widgets&subpage=$1 # subnets RewriteRule ^subnets/(.*)/(.*)/ipdetails/(.*)/$ index.php?page=subnets&section=$1&subnetId=$2&ipaddrid=$3 [L] RewriteRule ^subnets/(.*)/(.*)/changelog/$ index.php?page=subnets&section=$1&subnetId=$2&sPage=changelog [L] RewriteRule ^subnets/(.*)/(.*)/(.*)/$ index.php?page=subnets&section=$1&subnetId=$2&sPage=$3 [L] RewriteRule ^subnets/(.*)/(.*)/$ index.php?page=subnets&section=$1&subnetId=$2 [L] RewriteRule ^subnets/(.*)/$ index.php?page=subnets&section=$1 [L] # folders RewriteRule ^folder/(.*)/(.*)/$ index.php?page=folder&section=$1&subnetId=$2 [L] RewriteRule ^folder/(.*)/$ index.php?page=folder&section=$1 [L] # vlans RewriteRule ^vlan/(.*)/(.*)/$ index.php?page=vlan&section=$1&vlanId=$2 [L] # vrfs RewriteRule ^vrf/(.*)/(.*)/$ index.php?page=vrf&section=$1&vrfId=$2 [L] # changelog override RewriteRule ^tools/changelog/(.*)/(.*)/$ index.php?page=tools&toolsId=changelog&cfilter=$1&climit=$2 [L] RewriteRule ^tools/changelog/(.*)/$ index.php?page=tools&toolsId=changelog&climit=$1 [L] # search override RewriteRule ^tools/search/(.*)$ index.php?page=tools&toolsId=search&ip=$1 [L] # devices override RewriteRule ^tools/devices/hosts/(.*)$ index.php?page=tools&toolsId=devices&deviceid=$1 [L] # tools RewriteRule ^tools/(.*)/$ index.php?page=tools&toolsId=$1 [L] RewriteRule ^tools/$ index.php?page=tools&toolsId=showAll [L] # admin RewriteRule ^administration/manageSection/sectionChangelog/(.*)/$ index.php?page=administration&adminId=sectionChangelog&sectionId=$1 [L] RewriteRule ^administration/(.*)/$ index.php?page=administration&adminId=$1 [L] RewriteRule ^administration/$ index.php?page=administration&adminId=showAll [L] 

手动将url中的https(不需要修改htaccess)产生以下内容:

在这里输入图像说明

它应该如下所示:

在这里输入图像说明

我是这样做的:

 RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R,L] 

它工作得很好。