【问题标题】:Unwanted default rewrite/alias不需要的默认重写/别名
【发布时间】:2012-12-03 00:21:45
【问题描述】:

在我的机器上,用户页面重定向到/是 userpage.html 或 userpage.php 的别名,即使在我没有设置任何重写规则之前,或者即使我关闭了重写。它一定是一些我不知道的默认设置。

我在 Fedora 上使用 apache,并没有弄乱默认配置,除了打开基于名称的虚拟主机

我得到了一些额外的奇怪结果,也许是相关的。此代码不起作用:

RewriteRule userpage/vidnum/(.*)$   userpage.php?vidnum=$1 [NC,L]

这个确实有效:

RewriteRule vidnum/(.*)$   userpage.php?vidnum=$1 [NC,L]

由于需要服务器托管灵活性,我编写的所有重写规则都必须存在于 .htaccess 中,顺便说一句。

我的虚拟主机是这样设置的 = AFAIK 没什么奇怪的:

<VirtualHost *:80>
    ServerAdmin webmaster@keryx.se
    DocumentRoot /home/gunther/arkiv/workspace/webbteknik
    ServerName wt.book
    ErrorLog logs/wt.book-error_log
    CustomLog logs/wt.book-access_log combined
    <Directory /home/gunther/arkiv/workspace/webbteknik>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

【问题讨论】:

  • 即使您在根文件夹中的 .htaccess 中将 RewriteEngine 设置为 Off(即关闭 mod_rewrite),是否会发生“默认重定向”?可能有一个名为 userpage 的文件夹,其中包含一个额外的 .htaccess 文件进行重定向?
  • 您可以编辑您的问题并从应用程序的根文件夹中发布您的 .htaccess 内容吗?

标签: apache mod-rewrite rewrite


【解决方案1】:

感谢一位 Twitter 朋友 (@bjori),我知道发生了什么。

正是内容协商导致了上述所有情况。

添加:

Options -MultiViews

在我的 .htaccess 中解决了这个问题。这使得这个问题成为mod-rewrite question: /test/method is rewritten to test.svg/method的欺骗

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-15
  • 1970-01-01
  • 2015-09-29
  • 2019-01-22
  • 2013-02-17
  • 2015-12-01
相关资源
最近更新 更多