【问题标题】:Apache loads relative URLS as HTTP when using HTTPSApache 在使用 HTTPS 时将相对 URL 加载为 HTTP
【发布时间】:2014-11-06 14:17:01
【问题描述】:

我正在尝试在我的网站上使用 SSL,但即使页面使用 https://

,具有相对 URL 的资源也会加载为 http://

这是我的 .htacces

Options +FollowSymLinks
RewriteEngine On


RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]

RewriteCond %{QUERY_STRING} ^(.*)=http [NC]

RewriteRule ^(.*)$ – [F,L]
RewriteCond %{http_host} ^tacticalghillies.nl [NC]
RewriteRule ^(.*)$ http://www.tacticalghillies.nl/$1 [L,R=301]

RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]

RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]

RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]

RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})

RewriteRule .* index.php [F]

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{REQUEST_URI} !^/index\.php

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php [L]

我在搞砸什么?

【问题讨论】:

  • RewriteEngine on ?
  • 啊,这是旧版本,抱歉,RewriteEngine 已开启

标签: apache .htaccess https


【解决方案1】:

很难理解你所有的“代码”。

我认为你可以在开头添加:

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA,L]

【讨论】:

  • 这个“代码”是 joomla 给你的混乱,当我添加规则时它会创建一个重定向循环
  • 试试[R=301,QSA,L]
  • tacticalghillies.nl 同样的错误,也许我应该删除所有的 joomla 垃圾并将所有内容重定向到 index.php?
  • 您在RewriteEngine On 正下方添加新规则?
  • 没有资源在控制台中为非 https 链接提供错误?
【解决方案2】:

不要乱用 HTACCESS(你可以很容易地搞砸你的 SEF URLS),只需使用 Joomla 全局配置并强制 SSL 始终打开。如果您打开该设置,任何 Joomla 页面都会自动使用 SSL。

【讨论】:

    猜你喜欢
    • 2019-07-17
    • 1970-01-01
    • 2011-10-01
    • 2018-02-28
    • 1970-01-01
    • 1970-01-01
    • 2014-09-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多