【问题标题】:Strange issue with .htaccess file unable to remove PHP extensions.htaccess 文件的奇怪问题无法删除 PHP 扩展
【发布时间】:2015-04-22 14:21:36
【问题描述】:

我在运行 Ubuntu 14.04 x64 的 VPS 上,并且我已启用 mod_rewrite

这有效(即正确重定向到 testfile.php):

RewriteRule ^othername$ testfile.php

但这没有(给我一个 404 错误,说“在此服务器上找不到请求的 URL /testfile”):

RewriteRule ^testfile$ testfile.php

所以我基本上不能将 URL 重定向到同名但具有 PHP 扩展名的文件。这两个示例都在本地使用 MAMP。 什么可能导致此问题?

【问题讨论】:

  • 这是一个真实的例子吗?访问日志条目?重写日志?
  • 我不知道是什么导致了这个问题,但也许这可以解决你的问题:RewriteRule ^(testfile)$ $1.php
  • 尝试在您的 .htaccess 顶部添加 Options -MultiViews
  • 谢谢,添加Options -MultiViews 成功了!

标签: php apache .htaccess ubuntu mod-rewrite


【解决方案1】:

正如 anubhava 所说,您只需在 .htaccess 顶部添加 Options -MultiViews

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 2020-07-20
    • 2012-05-14
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多