2013-05-09 38 views
0

嗨,朋友。我正在用重寫規則創建一個.htaccess文件。它在本地主機上運行良好,但在實時服務器上無法正常工作。我的主機使用Window服務器。重寫規則不能在IIS中使用PHP服務器

我在.htaccess文件寫了這個規則:

RewriteEngine On 
RewriteBase /project_name/ 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !example.php 
RewriteCond %{REQUEST_URI} !(.*)/$ 

RewriteRule (.*) pages.php?page_slug=$1 [L] 
+0

'.htaccess'是Apache httpd專有的文件。 IIS使用不同的方法。看看[this](http://www.iis.net/downloads/microsoft/url-rewrite)以及其他鏈接的頁面。 – Lukas 2013-05-09 17:11:19

+0

您需要將這些規則寫入網站根目錄下的web.config文件中(假設您的主機具有可用的模塊)。 – cheesemacfly 2013-05-10 20:22:52

回答

0

對於WordPress的IIS服務器上運行的情況下,你需要創建在根目錄下的Web.config然後把下面的代碼,

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <rule name="wordpress" 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> 
    </system.webServer> 
</configuration>