簡體   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