2016-01-26 47 views
1

我想关闭SSL站点的/ builder目录中的SSL。 我已经尝试了许多不同的.htaccess配置,但无论是我把它们放在错误的顺序或他们不工作。.htaccess针对特定目录关闭SSL

这里是我当前的.htaccess:

Options +Indexes 
RewriteEngine on 
Redirect 301 /index.html /index.php 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.cdghost.xyz/$1 [R,L] 
ErrorDocument 400 /400.html 
ErrorDocument 401 /401.html 
ErrorDocument 403 /403.html 
ErrorDocument 404 /404.html 
ErrorDocument 500 /500.html 
ErrorDocument 502 /502.html 
ErrorDocument 503 /503.html 
ErrorDocument 504 /504.html 

谢谢!

+1

不要这样做。你为什么要*主动禁用安全性*? – Sammitch

+0

我有一个脚本运行,不能与ssl启用。 –

+0

修复脚本。 – Sammitch

回答

1

试试这个

Options +Indexes 
RewriteEngine on 
Redirect 301 /index.html /index.php 

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^((?!builder/).*)$ https://www.cdghost.xyz/$1 [R,L] 
ErrorDocument 400 /400.html 
ErrorDocument 401 /401.html 
ErrorDocument 403 /403.html 
ErrorDocument 404 /404.html 
ErrorDocument 500 /500.html 
ErrorDocument 502 /502.html 
ErrorDocument 503 /503.html 
ErrorDocument 504 /504.html 

您还可以使用的RewriteCond排除从HTTPS rediretion /建设者:

RewriteEngine on 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} !^/builder 
RewriteRule ^(.*)$ https://www.cdghost.xyz/$1 [R,L] 

的的RewriteCond检查,以确保请求的URI不/建设者/ ..,如果它不是/ builder ..,那么请求被重定向到SSL。

+1

非常感谢!这很好。 –