为引用者停止https

时间:2017-09-12 14:30:22

标签: .htaccess https http-referer

我有一个https网站,其中有一个隐藏的用户区。用户可以从那里链接到http站点。使用引荐来源,该网站可确保使用者来自我的网站。其他访问尝试被阻止。

由于我的网站更改为https,因此引荐工具不再有效。

到目前为止我的解决方案尝试: 在我的htaccess里面,我想停止网站上只有一个文件的https。链接在哪里。到目前为止我的htaccess。

ErrorDocument 404 /404.php

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/Mitgliederservice/Infoline/index\.php$ [NC]
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

1 个答案:

答案 0 :(得分:1)

我不明白您是要排除一个页面还是仅强制将一个页面强制为https,因此,如果要排除一个特定页面,请使用以下代码:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} !^/path/to/yourpage\.php$ 
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]

否则使用以下代码:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^/path/to/yourpage\.php$ 
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
相关问题