2013-02-11 23 views
1

我試圖做一個靜態網站b2evolution這個wget的行:改寫....到index.php%3F .... HTML

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 

我recive瀏覽器的這個錯誤:

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修改'?'的url類型(帶'?') '%3F'。我已經tryed有:

RewriteRule ^index.php\? index.php\%3F [QSA,NE] 

但我recive在日誌中的錯誤:

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的參數來解決?

回答

1

如果文件名包含?,以下規則應該可以工作。

RewriteEngine On 
RewriteCond %{QUERY_STRING} (.+) 
RewriteRule ^(index\.php)$ $1\%3F%1 [L] 

其工作原理如下:

  • RewriteRule評估第一,匹配獲得存儲在$ 0 $ 1,...
  • 成功後,RewriteCond評估和匹配得到存儲在%0,%1,...
  • 最後,這兩個匹配結合起來
  • 字面%字符轉義爲\%(必要的,因爲%n用於的RewriteCond反向引用)
  • %3F?的URL編碼形式,否則表示查詢字符串的開頭
  • .+用於匹配的非空查詢字符串
+0

It作品。讓我來看看Cond吧,你會得到任何帶有0個或更多字符的查詢,以後我們可以使用%i(在這種情況下i = 1)。比你在(1)$ arg之間捕獲。內部的點必須受到保護,因爲它意味着任何字符。最後,我們告訴mod_rewrite如何轉換recived url。 – jedi 2013-02-11 20:06:42

+0

幾乎正確。我編輯了我的答案。 – 2013-02-11 20:20:43

+0

準確得多! TNX。 – jedi 2013-02-11 21:59:51

0

請參閱--restrict-file-names選項。雖然不完全適用於這一特定目的,--restrict-文件名=窗口可能會幫助你前進:

--restrict-文件名=模式

更改其在遠程URL中的字符在 生成本地文件名時必須被轉義。 [...]

當給出「窗口」時,Wget會轉義字符\,|,/,:,?,「, *,<,>和控制字符在範圍0-31和128- 159.除此之外,Windows模式下的Wget使用+而不是:以 分隔本地文件名中的主機和端口,並且使用@代替 將文件名的查詢部分與其餘部分分開,因此, 在Unix模式下將保存爲www.xemacs.org:4300/search.pl?input=blah 的URL在Windows模式下將被保存爲 www.xemacs.org+4300/[email protected]=blah。