htacceess到web.config的wordpress和codeigniter

问题描述

我在根文件夹上有codeigniter。然后在子文件夹(主页)上使用wordpress。以下是htaccess:

#RewriteCond %{HTTPS} =on
Options -Indexes
IndexIgnore * 
Options +FollowSymLinks
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.PHP/$1 [PT,L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
RewriteRule ^$ home [L]

我已经制作了 web.config ,它删除 index.PHP 用于codeigniter并在访问根域时重定向wordpress(主文件夹)。但是在以下 web.config 中,我遇到了3个问题:

  1. wordpress永久链接不起作用。
  2. codeigniter仅在与 index.PHP 一起使用的网址时有效。
  3. 野生动物园总是显示403 Forbidden. Access denied

web.config

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Imported Rule 1" stopProcessing="true" >
                        <match url="^$" />
                        <action type="Rewrite" url="/home" />
                    </rule>
                
                    <rule name="Imported Rule 2" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.PHP?url={R:1}" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
    </configuration>

PS:网站托管在Windows plesk(黑曜石)上

解决方法

尝试一下:

<?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <rewrite>
                <rules>
                    <rule name="Imported Rule 2" stopProcessing="true"  patternSyntax="Wildcard">
                        <match url="*" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                             <add input="{REQUEST_URI}" matchType="Pattern" pattern="/home/*" negate="true" />  
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
        </system.webServer>
        
  <location path="home">
    <system.webServer>
      <rewrite>
        <rules>
          <remove name="home" />
          <rule name="home" patternSyntax="Wildcard">
            <match url="*"/>
            <conditions>
              <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
              <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
            </conditions>
            <action type="Rewrite" url="home/index.php" redirectType="Found"/>
          </rule>
        </rules>
      </rewrite>
    </system.webServer>
  </location>
    </configuration>