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

apache-将“?”字符视为文件名的一部分

  •  1
  • jiwopene  · 技术社区  · 7 年前

    我有一个目录,里面有很多包含问号字符的文件。我如何禁用Apache中的查询字符串支持(可能使用mod_rewrite),以便 ? 作为一个普通的角色?我不想使用更改文件名 .

    当前行为:

    Request URI: /dir/subdir/file?abcdef.txt
    Served file: /dir/subdir/file
    

    Request URI: /dir/subdir/file?abcdef.txt
    Served file: /dir/subdir/file?abcdef.txt
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   jiwopene    7 年前

    这对我很有用:

    RewriteEngine on
    RewriteCond %{QUERY_STRING} .
    RewriteRule (.*) $1\%3f%{QUERY_STRING} [QSD]