【问题标题】:Apache redirect/rewrite of https hostname to https full URLApache 将 https 主机名重定向/重写为 https 完整 URL
【发布时间】:2012-07-10 17:09:21
【问题描述】:

已经进行了 Apache 重写以将 URL 从 http 重定向到 https,这可以正常工作

RewriteCond %{HTTPS} off

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

但是https://hostname 转到“itworks!”页面

https://hostname 重定向到https://hostname/sub1/sub2 的语法是什么

谢谢

【问题讨论】:

  • 尝试了许多不同的选项,但由于某种原因无法在 https 模式下重写 URL。最后,我在 itworks 上放了一个 http 重定向!页面,而不是最优雅的解决方案。

标签: apache redirect https rewrite


【解决方案1】:

把它放在你拥有的规则之后

RewriteCond %{HTTPS} on
RewriteRule ^$ /sub1/sub2 [L]

如果您希望浏览器地址栏中的实际 URL 更改为 /sub1/sub2,则将括号中的 [L] 更改为 [R=301,L]

【讨论】:

  • 感谢您的回复,它似乎没有工作。尝试了您的代码的一些变体,但每次都没有切换。
猜你喜欢
  • 1970-01-01
  • 2018-02-20
  • 2016-07-16
  • 2016-08-30
  • 2011-08-18
  • 1970-01-01
  • 1970-01-01
  • 2018-08-03
  • 1970-01-01
相关资源
最近更新 更多