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

时间:2010-03-18 05:36:55

标签: apache

我使用wget -m -k -E抓了一堆页面。生成的文件的名称格式为foo.php?bar.html。 Apache猜到了之后的一切?是一个查询字符串,有没有办法告诉它忽略?作为查询字符串分隔符(并将foo.php?bar.html视为请求的文件,而不是foo.php)?

为了节省您的wget手册页之旅:
-m:递归镜像
-E:foo.php?bar变成了foo.php?bar.html
-k:转换页面中的链接(foo.php?bar现在链接到所有页面内的foo.php?bar.html,以便正确显示)

2 个答案:

答案 0 :(得分:4)

会逃避吗?作为%3F的伎俩?

答案 1 :(得分:3)

Apache v1 used to handle them, however v2 does not.

I did it using mod_rewrite. Nathans' suggestion in a form of code:

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