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

有没有办法让Apache为文件名中带有问号的文件提供服务?

  •  5
  • ldrg  · 技术社区  · 14 年前

    我用wget-m-k-e抓取了一堆页面,结果文件的名称是foo.php?bar.html.阿帕奇猜中了之后的一切?是查询字符串,是否有方法告诉它忽略?作为查询字符串分隔符(参见foo.php?是否将bar.html作为请求的文件而不是foo.php)?

    要保存到wget手册页的旅行,请执行以下操作:
    -M:递归镜像
    -邮箱:foo.php?酒吧变成foo.php?条形图.html
    -K:转换页面中的链接(foo.php?现在条链接到foo.php?所有页面内的bar.html,以便正确显示)

    2 回复  |  直到 9 年前
        1
  •  4
  •   Nathan Osman    14 年前

    会逃离吗?就像%3f一样?

        2
  •  3
  •   Artur ČuvaÅ¡ov    9 年前

    Apachev1曾经处理过它们,但是v2没有。

    我用mod ou rewrite完成了。内森以代码的形式提出的建议:

    RewriteEngine On 
    
    # Convert ? -> %3F in queries and add .html to the end of the filename
    RewriteCond %{ENV:REDIRECT_STATUS} !200 
    RewriteCond %{QUERY_STRING} !^$ 
    RewriteRule ^(.*)$ /$1\%3F%{QUERY_STRING}.html [L,NE]
    
    # An addition for *.php files without question mark in its name, adding html to the end of the filename
    RewriteRule ^(.*?)\.php$ $1.php.html