繁体   English   中英

重写规则在PHP的IIS服务器中不起作用

[英]Rewrite Rule not Working in IIS Server with PHP

朋友们 我正在创建带有重写规则的.htaccess文件。 它在localhost中可以正常工作,但是在实时服务器上却无法正常工作。 我的托管使用Window服务器。

我在.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]

对于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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM