2009-11-22 54 views
6

我正在將一個WordPress博客從Apache移動到IIS。這只是幾個星期,直到我改變了。但我所能得到的只是主頁。其他一切都會引發錯誤。替代Apache的.htaccess文件的IIS?

我想我的問題是在.htaccess文件:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
#END WordPress 

是否有IIS的東西相當於這個?

謝謝。

+2

你在Windows上使用IIS或Apache? – 2009-11-22 07:28:25

+0

另外,它拋出了什麼樣的錯誤? – 2009-11-22 09:52:37

+0

使用IIS。錯誤:如果我點擊一個有子目錄的鏈接,如mysite.com/news,我會得到一個404錯誤。 如果我在地址欄中添加/index.php,我沒有指定輸入文件。 – user80151 2009-11-22 17:02:48

回答

2

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite.

檢查WordPress的食品,特別是Permalinks Without Mod Rewrite節,因爲它有關於你的環境的永久鏈接信息(下面的一些信息,檢查鏈接的完整信息,因爲它是官方文檔):

If you are using IIS 7 and have admin rights on your server, you can use Microsoft's URL Rewrite Module instead. Though not completely compatible with mod_rewrite, it does support WordPress's pretty permalinks. Once installed, open the web.config file in the WordPress folder and add the following rule to the system.webServer element.

<rewrite> 
    <rules> 
     <rule name="Main Rule" stopProcessing="true"> 
      <match url=".*" /> 
      <conditions logicalGrouping="MatchAll"> 
       <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
       <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
      </conditions> 
      <action type="Rewrite" url="index.php" /> 
     </rule> 
    </rules> 
</rewrite> 
0

創建一個WordPress的新安裝,然後有選擇地導入表。

問題當然是固定鏈接。但我發現解決這個問題的最簡單方法是使用舊站點的相同結構固定鏈接(幸運的是,它尚未被刪除,因此我可以在管理中找到它),然後導入除用戶表以外的所有內容。

如果您導入用戶表,則會丟失新設置中的管理員登錄名。

1

"Pretty" permalinks usually require mod_rewrite, and IIS (common on Windows servers) does not support mod_rewrite.

您是否使用IIS6或7,你也可以使用在IIS上重寫引擎 - 其中許多是支持mod_rewrite的語法。
IIRF是一個不錯的選擇,可以同時使用IIS6和7.(Vista,WS2003,2008)。

10

我想你會在這裏找到了答案 - How To Set Pretty Permalinks in Wordpress Runs On IIS 7我想你需要把一個web.config文件中的根文件夾,如:

<?xml version="1.0"?> 
<configuration> 
<system.webServer> 
<defaultDocument> 
    <files> 
    <remove value="index.php" /> 
    <add value="index.php" /> 
    </files> 
</defaultDocument> 
<rewrite> 
<rules> 
    <rule name="Main Rule" stopProcessing="true"> 
     <match url=".*" /> 
     <conditions logicalGrouping="MatchAll"> 
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="index.php/{R:0}" /> 
    </rule> 
</rules> 
</rewrite> 
</system.webServer> 
</configuration>