2013-05-09 32 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>