代码之家  ›  专栏  ›  技术社区  ›  davidtbernal

mod rewrite question:/test/method被重写为test.svg/method

  •  0
  • davidtbernal  · 技术社区  · 16 年前

    我(对我)注意到一个奇怪的问题 mod_rewrite 事情发生了。修复它对我来说并不重要,重要的是弄清楚到底发生了什么。基本上,我有一个名为 test.svg index.php . 我的期望,基于我的 .htaccess 那是什么档案 http://localhost/test.svg 能帮我弄到 .svg http://localhost/test/action index.php/test/action . 相反,后者显然被改写为 test.svg/action

    在此服务器上找不到请求的URL/test.svg/action。

    这是我的 文件:

    # Turn on URL rewriting
    RewriteEngine On
    
    # Protect application and system files from being viewed
    # RewriteRule ^(application|modules|system) - [F,L]
    
    # Allow any files or directories that exist to be displayed directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # Rewrite all other URLs to index.php/URL
    RewriteRule .* index.php/$0 [PT,L]
    

    我在Ubuntu上使用Apache2.2.12(通过 apt-get

    正如我所说,解决这个问题将是微不足道的,我只是经常感到困惑 修改 我想知道这里发生了什么。

    1 回复  |  直到 16 年前
        1
  •  2
  •   Stuart Sierra    16 年前

    http://httpd.apache.org/docs/2.0/content-negotiation.html#multiviews

    您可以使用以下指令禁用.htaccess中的内容协商:

    Options -MultiViews
    

    通过将这些指令添加到Apache配置中,您可以获得有关mod_rewrite正在做什么的更多信息(它们在.htaccess中不起作用):

    RewriteLog /path/to/rewrite.log
    RewriteLogLevel 3
    

    推荐文章