2015-03-19 67 views
2

我在根目录上获得了CI文件夹,并在子目录上获得了Wordpress。从CI和Word中删除index.php

经过几天的努力后,我发现问题是: - 在WP web.config 之前读取CI web配置,所以CI index.php被成功删除,但不是WP的。

访问website.com调用CI web.config,进行处理。
访问website.com/blog调用CI web.config,进行处理。

如果URL中没有博客,只是添加的index.php
如果URL中包含的博客,添加index.php的网站后,再经过博客添加其他的index.php

问:
怎么办匹配URL“IF URL有博客然后添加另一个index.php”? 如果我错了,请纠正我。

任何帮助确定CI目录上正确的webconfig将不胜感激!

original URL: 

CI

website.com/index.php/en/user/ 

WP

website.com/index.php/blog/index.php/ 



website.com/en/user => codeigniter with the controller User 
website.com/blog/hello-world => error 404 
website.com/blog/index.php/hello-world => Good result 

/apps 
/system 
/blog 
    ../web.config WP =>remove WP index.php 
    ../index.php 

/web.config CI =>remove CI index.php 
/index.php 

web配置以除去CI的index.php

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
    <rules> 
     <rule name="RuleRemoveIndex" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions> 
       <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/{R:1}" appendQueryString="true"/> 
     </rule> 

    </rules> 
    </rewrite> 

    </system.webServer> 
</configuration> 

/博客=> WP应用

web.config中的WP目录删除WP的index.php

<?xml version="1.0" encoding="UTF-8"?> 
    <configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
      <rule name="WordPress Rule 1" stopProcessing="true"> 
       <match url="^index\.php$" ignoreCase="false" /> 
       <action type="None" /> 
      </rule> 
      <rule name="WordPress Rule 2" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> 
       <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> 
      </rule> 
      <rule name="WordPress Rule 3" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> 
       <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> 
      </rule> 
      <rule name="WordPress Rule 4" stopProcessing="true"> 
       <match url="^" ignoreCase="false" /> 
       <conditions logicalGrouping="MatchAny"> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> 
       </conditions> 
       <action type="None" /> 
      </rule> 
      <rule name="WordPress Rule 5" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" /> 
       <action type="Rewrite" url="{R:2}" /> 
      </rule> 
      <rule name="WordPress Rule 6" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> 
       <action type="Rewrite" url="{R:2}" /> 
      </rule> 
      <rule name="WordPress Rule 7" stopProcessing="true"> 
       <match url="." ignoreCase="false" /> 
       <action type="Rewrite" url="index.php" /> 
      </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
    </configuration> 

UPDATE:在根目录下 web配置是否有博客/ URL,重写的index.php 我发现,如果我删除的web配置关于CI的规则,它不会影响WP。 它将加载website.com/blog/hello-world well

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <rewrite> 
      <rules> 

       <rule name="wordpress1" patternSyntax="Wildcard"> 
      <match url="blog[/]?$"/> 
       <conditions> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/> 
       </conditions> 
      <action type="Rewrite" url="index.php/{R:1}"/> 
     </rule> 
     <rule name="RuleRemoveIndex" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions> 
       <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/{R:1}" appendQueryString="true"/> 
     </rule> 
      </rules> 
     </rewrite> 
    </system.webServer> 
</configuration> 

结果:在每个目录中使用的web.config 404错误

+0

尝试配置文件合并成一个(根目录),并用预先准备的WordPress规则'博客/' – 2015-03-19 08:34:37

回答

0

溶液。 当我删除CI web.config的规则时,我发现我可以很好地加载WP。

我用这对CI的web.config

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
    <rewrite> 
    <rules> 
     <rule name="RuleRemoveIndex" stopProcessing="true"> 
      <match url="^(.*)$" ignoreCase="false" /> 
      <conditions> 
       <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/{R:1}" appendQueryString="true"/> 
     </rule> 

    </rules> 
    </rewrite> 

    </system.webServer> 
</configuration> 

对WP的web.config

<?xml version="1.0" encoding="UTF-8"?> 
    <configuration> 
    <system.webServer> 
    <rewrite> 
     <rules> 
     <clear/> => add clear to clear the predefined connection strings 
      <rule name="WordPress Rule 1" stopProcessing="true"> 
       <match url="^index\.php$" ignoreCase="false" /> 
       <action type="None" /> 
      </rule> 
      <rule name="WordPress Rule 2" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" /> 
       <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" /> 
      </rule> 
      <rule name="WordPress Rule 3" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" /> 
       <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" /> 
      </rule> 
      <rule name="WordPress Rule 4" stopProcessing="true"> 
       <match url="^" ignoreCase="false" /> 
       <conditions logicalGrouping="MatchAny"> 
        <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" /> 
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" /> 
       </conditions> 
       <action type="None" /> 
      </rule> 
      <rule name="WordPress Rule 5" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" /> 
       <action type="Rewrite" url="{R:2}" /> 
      </rule> 
      <rule name="WordPress Rule 6" stopProcessing="true"> 
       <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> 
       <action type="Rewrite" url="{R:2}" /> 
      </rule> 
      <rule name="WordPress Rule 7" stopProcessing="true"> 
       <match url="." ignoreCase="false" /> 
       <action type="Rewrite" url="index.php" /> 
      </rule> 
     </rules> 
    </rewrite> 
    </system.webServer> 
    </configuration>