Apache 从index.php重写?。。。。要索引.php%3F…html

Apache 从index.php重写?。。。。要索引.php%3F…html,apache,mod-rewrite,wget,Apache,Mod Rewrite,Wget,我正在尝试使用以下wget行创建一个静态的b2evolution站点: wget -nv -b -m -k -p -E -erobots=off --tries=5 --exclude-directories=calendar,users,user --domains directory http://site.com 它生成如下文件: index.php?blog=2&cat=21.html 正在尝试访问以下网址: http://site.com/index.php?b

我正在尝试使用以下wget行创建一个静态的b2evolution站点:

  wget -nv -b -m -k -p -E -erobots=off --tries=5 --exclude-directories=calendar,users,user --domains directory http://site.com
它生成如下文件:

  index.php?blog=2&cat=21.html
正在尝试访问以下网址:

  http://site.com/index.php?blog=2&cat=21.html
我在浏览器上收到此错误:

  Not Found
  The requested URL /index.php was not found on this server.
在error.log上显示以下内容:

  [Mon Feb 10 19:02:49 2013] [error] [client xx.xx.xx.xx] script '/var/www/site.com/htdocs/index.php' not found or unable to stat, referer: http://site.com/index.php
但我可以使用%3F代替“?”:

  http://site.com/index.php%3Fblog=2&cat=21.html
我的范围是允许使用apache rewrite_mod使用“%3F”修改“?”,使用旧类型的url(带“?”)访问站点。我尝试过:

  RewriteRule ^index.php\? index.php\%3F [QSA,NE]
但我在日志中收到此错误:

  Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

有没有办法用mod_rewrite或其他wget参数解决问题?

如果文件名包含
,则以下规则应该有效

RewriteEngine On
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(index\.php)$ $1\%3F%1 [L]
其工作原理如下:

  • RewriteRule
    首先计算,匹配项存储在$0、$1、
  • 成功后,
    RewriteCond
    将被计算并将匹配项存储在%0、%1、
  • 最后,将这两个匹配合并
  • 文本
    %
    字符被转义为
    \%
    (由于
    %n
    用于重写第二次回写引用,因此必须转义)
  • %3F
    的URL编码形式,否则表示查询字符串的开头
  • +
    用于匹配非空查询字符串

如果文件名包含
,则以下规则应适用

RewriteEngine On
RewriteCond %{QUERY_STRING} (.+)
RewriteRule ^(index\.php)$ $1\%3F%1 [L]
其工作原理如下:

  • RewriteRule
    首先计算,匹配项存储在$0、$1、
  • 成功后,
    RewriteCond
    将被计算并将匹配项存储在%0、%1、
  • 最后,将这两个匹配合并
  • 文本
    %
    字符被转义为
    \%
    (由于
    %n
    用于重写第二次回写引用,因此必须转义)
  • %3F
    的URL编码形式,否则表示查询字符串的开头
  • +
    用于匹配非空查询字符串
请参阅--restrict file names选项。虽然并非完全用于此特定目的,-restrict file name=windows可能会帮助您:

--限制文件名=模式

更改在远程URL中找到的字符在执行过程中必须转义 生成本地文件名。[……]

当给定“窗口”时,Wget将转义字符\、|、/、:、?、“, *,以及范围为0--31和128--159的控制字符。除此之外,Windows模式下的Wget使用+而不是:to 以本地文件名分隔主机和端口,并使用@而不是?来 将文件名的查询部分与其余部分分开。因此, 保存为www.xemacs.org:4300/search.pl?input=blah的URL 在Unix模式下,将另存为 www.xemacs.org+4300/search。pl@input=Windows模式下的blah

请参阅--restrict file names选项。虽然并非完全用于此特定目的,-restrict file names=windows可能会帮助您:

--限制文件名=模式

更改在远程URL中找到的字符在执行过程中必须转义 生成本地文件名。[…]

当给定“窗口”时,Wget将转义字符\、|、/、:、?、“, *,以及范围为0-31和128-159的控制字符。除此之外,Windows模式下的Wget使用+而不是:to 以本地文件名分隔主机和端口,并使用@而不是?到 将文件名的查询部分与其余部分分开。所以,, 保存为www.xemacs.org:4300/search.pl?input=blah的URL 在Unix模式下,将另存为 www.xemacs.org+4300/search。pl@input=Windows模式下的blah


它起作用了。让我解释一下。。通过Cond,您可以得到任何具有0个或更多字符的查询,稍后我们可以将其与%i一起使用(在本例中,i=1)。而不是在()和$1参数之间。里面的点必须被保护,因为它意味着任何字符。最后,我们告诉mod_重写如何转换接收到的url。它是有效的。让我解释一下。。通过Cond,您可以得到任何具有0个或更多字符的查询,稍后我们可以将其与%i一起使用(在本例中,i=1)。而不是在()和$1参数之间。里面的点必须被保护,因为它意味着任何字符。最后,我们告诉mod_重写如何转换接收到的url。