【问题标题】:RewriteRule working on http but breaks on httpsRewriteRule 在 http 上工作,但在 https 上中断
【发布时间】:2014-11-06 16:40:24
【问题描述】:

我在 htaccess 中有一些 RewriteRule,以便为我的登录页面提供一些漂亮的 url。该网址可能看起来像 www.site.com/new-document,而我的 RewriteRule 将使 www.site.com/index.php?page=new-document

这样我可以留下漂亮的 url 并使用 index.php 来根据页面变量更改文本。

在 http 上一切正常,但是一旦我将 https 添加到 url,我就会收到 Not Found 错误,因为 RewriteRule 没有触发。

这是我的 htaccess 代码的副本

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteRule    ^new-document$            index.php?page=new-document
RewriteRule    ^old-document$            index.php?page=old-document

</IfModule>

【问题讨论】:

  • 确保 https 站点的 DocumentRoot 与 http 相同

标签: php apache .htaccess mod-rewrite


【解决方案1】:

蚱蜢和anubhava 为我指明了正确的方向!

我的问题是 https 虚拟主机没有 AllowOverride All 指令。

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

【讨论】:

    【解决方案2】:

    你能在没有 RewriteRule 的情况下访问 HTTPS URL 吗?听起来 Apache 可能正在使用不同的虚拟主机或根本不接受 HTTPS。

    【讨论】:

      猜你喜欢
      • 2013-08-18
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      • 2020-05-06
      • 2020-12-26
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      相关资源
      最近更新 更多