2015-10-13 59 views
0

我想重寫一個Mediawiki網站中的網址,並且一切看起來正在根據失敗的請求日誌文件輸出工作。然而,正在顯示的頁面是原始頁面,而不是重寫中的網址。基本上,我想

www.website.com/State/City/Category



www.website.com/index.php?title=Special:RunQuery/CategoryPage&CategoryPage[State]= State&CategoryPage[City]=City&CategoryPage[Category]=Category&wpRunQuery=true

而似乎是展示在

www.website.com/index.php?title=State/City/Category

印刷_SERVER頁面顯示的頁面顯示QUERY_STRING作爲特別:RunQuery頁,但在其他方面所有其他變量顯示index.php或/ State/City/Category。我的web.config重寫規則看起來像這樣:Web配置重寫規則不顯示正確的頁面

<rewrite> 
    <rules> 
     <rule name="Root Hit Redirect" stopProcessing="true"> 
      <match url="^$" /> 
      <action type="Rewrite" url="/index.php?title=Main_Page" /> 
     </rule> 
     <rule name="RedirectUserFriendlyURL1" stopProcessing="true"> 
      <match url="^index\.php$" /> 
      <conditions> 
       <add input="{REQUEST_METHOD}" pattern="^POST$" /> 
       <add input="{QUERY_STRING}" pattern="^title=([^=&amp;]+)$" /> 
      </conditions> 
      <action type="Redirect" url="{C:1}" appendQueryString="false" /> 
     </rule> 
     <rule name="RewriteUserFriendlyCategoryURL" stopProcessing="true"> 
      <match url="^([^/]+)/([^/]+)/([^/]+)/?$" /> 
      <conditions> 
       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php?title=Special:RunQuery/CategoryPage&amp;CategoryPage[State]={UrlDecode:{R:1}}&amp;CategoryPage[City]={UrlDecode:{R:2}}&amp;CategoryPage[Category]={UrlDecode:{R:3}}&amp;wpRunQuery=true" /> 
     </rule> 
     <rule name="RewriteUserFriendlyURL1" stopProcessing="true"> 
      <match url="^(.+)$" /> 
      <conditions> 
       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php?title={UrlDecode:{R:1}}" /> 
     </rule> 
    </rules> 
</rewrite> 

感謝任何幫助,以弄清楚這一個。現在我已經打了2天腦子。謝謝!

回答

0

我想你的規則本地和他們的工作,你所指出的,要求: 測試:
RequestURL = 「/州/市/分類」

將其正確改寫爲: 「本地主機:80 /指數?.PHP標題=特殊:RunQuery/CategoryPage & CategoryPage [狀態] =國家& CategoryPage [城市] =城市& CategoryPage [類別] =類別& wpRunQuery =真正的」

我的建議是使用失敗請求跟蹤: http://www.iis.net/learn/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules ,這應該告訴你到底發生了什麼。

+0

讚賞您檢查出來。我嘗試了失敗的請求追蹤,就像我上面所說的,一切似乎都沒問題。在日誌結尾處,它執行了一個看起來不錯的重寫操作,規則評估顯示了新的查詢字符串,重寫結束顯示了index.php的請求url,然後它向完整正確的字符串發出請求,然後以200成功。我想知道的是,也許Mediawiki正在尋找其他的東西,並根據其他變量提供不同的頁面。 Request_URI仍然設置爲/ State/City/Category。你可以改變web.config中的Request_URI和其他_Server變量嗎? –

0

好吧,我想,因爲卡洛斯說web.config看起來不錯,它一定是Mediawiki,果然我找到了一個地方,它檢查並使用$ _SERVER ['REQUEST_URI']。這可能會在URL的Rewrite for Apache中更改,但它不在IIS中。幸運的是我設法修改了LocalSettings.php中的一個變化,所以yay沒有mod到核心代碼。因此,如果其他人對IIS和Mediawiki或IIS和任何其他PHP Apache中心站點有此問題,則可以在以下代碼中添加以下代碼:

$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']."?".$_SERVER['QUERY_STRING'];