【问题标题】:.htaccess turn SSL off for specific directory.htaccess 关闭特定目录的 SSL
【发布时间】:2016-01-26 23:24:05
【问题描述】:

我想为我的站点的 /builder 目录关闭 SSL。 我尝试了许多不同的 .htaccess 配置,但要么我将它们按错误的顺序放置,要么它们不起作用。

这是我当前的 .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

谢谢!

【问题讨论】:

  • 不要这样做。为什么要主动禁用安全性
  • 我正在运行的脚本在启用 ssl 的情况下无法运行。
  • 脚本不是我写的,虽然我是和创作者一起工作的。

标签: php apache .htaccess ssl


【解决方案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 将 /builder 从 HTTPS 重定向中排除:

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

RewriteCond 检查以确保请求的 uri 不是 /builder/.. ,如果不是 /builder..,则将请求重定向到 SSL。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-17
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-15
    相关资源
    最近更新 更多