我运行了一个小型bootstrap themes网站,允许用户上传主题和模板。
我已经能够通过我的.htaccess文件将任何非SSL连接重定向到https:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
我现在需要将用户重定向到非SSL,特别是一页。这是一个包含iframe的页面,该iframe从主题作者网站加载预览,并且这些网站并不总是通过SSL提供。
网址始终带有“预览”字样,前面带有支部。
这是我尝试过的,不幸的是没有成功:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/preview [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} ^/preview [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
以下是两个例子:
非预览链接: http://www.bootstrapcovers.com/bootstrap-themes/all/free/sort.downloads/page.1
预览链接 http://www.bootstrapcovers.com/preview/1/adminlte-admin-control-panel
知道为什么它不起作用或我在.htaccess文件中缺少什么?
谢谢, -Paul
答案 0 :(得分:0)
使用THE_REQUEST
代替REQUEST_URI
,这可能会因其他模块或规则而发生变化:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} !\s/+preview [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} \s/+preview [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
# other rules go here
还要确保清除浏览器缓存。